The script begins by setting global print options. A DATA step is used to construct the 'account' dataset by reading company information (name, debt, account number, town) provided directly via DATALINES. Then, PROC SORT is applied to sort this 'account' dataset by the 'town' variable, then by 'company' (enterprise), storing the sorted result in a new dataset called 'bytown'. Finally, PROC PRINT is used to display the contents of the 'bytown' dataset, presenting specific columns (company, town, debt, accountnumber) and applying titles to the report to clearly identify customers with past-due accounts, listed alphabetically by town.
Data Analysis
Type : INTERNAL_CREATION
The data for the initial 'account' dataset is directly integrated into the script via `datalines` instructions within the DATA step. No external data sources (files, databases) are used.
1 Code Block
DATA STEP Data
Explanation : This DATA step block creates a temporary dataset named 'account'. It reads raw text data provided via the `datalines` instruction, defining four variables: 'Company' (character string), 'Debt' (numeric), 'AccountNumber' (numeric), and 'Town' (character string), with their respective positions and lengths in the data lines.
Copied!
data account;
input Company $ 1-22 Debt 25-30 AccountNumber 33-36
Town $ 39-51;
datalines;
Paul's Pizza 83.00 1019 Apex
World Wide Electronics 119.95 1122 Garner
Strickland Industries 657.22 1675 Morrisville
Ice Cream Delight 299.98 2310 Holly Springs
Watson Tabor Travel 37.95 3131 Apex
Boyd & Sons Accounting 312.49 4762 Garner
Bob's Beds 119.95 4998 Morrisville
Tina's Pet Shop 37.95 5108 Apex
Elway Piano and Organ 65.79 5217 Garner
Tim's Burger Stand 119.95 6335 Holly Springs
Peter's Auto Parts 65.79 7288 Apex
Deluxe Hardware 467.12 8941 Garner
Pauline's Antiques 302.05 9112 Morrisville
Apex Catering 37.95 9923 Apex
;
1
DATA account;
2
INPUT Company $ 1-22 Debt 25-30 AccountNumber 33-36
3
Town $ 39-51;
4
DATALINES;
5
Paul's Pizza 83.00 1019 Apex
6
World Wide Electronics 119.95 1122 Garner
7
Strickland Industries 657.22 1675 Morrisville
8
Ice Cream Delight 299.98 2310 Holly Springs
9
Watson Tabor Travel 37.95 3131 Apex
10
Boyd & Sons Accounting 312.49 4762 Garner
11
Bob's Beds 119.954998 Morrisville
12
Tina's Pet Shop 37.95 5108 Apex
13
Elway Piano and Organ 65.79 5217 Garner
14
Tim's Burger Stand 119.956335 Holly Springs
15
Peter's Auto Parts 65.79 7288 Apex
16
Deluxe Hardware 467.12 8941 Garner
17
Pauline's Antiques 302.059112 Morrisville
18
Apex Catering 37.959923 Apex
19
;
2 Code Block
PROC SORT
Explanation : This block uses the PROC SORT procedure to sort the 'account' dataset. The sorting is performed first by the 'town' variable, then by the 'company' variable within each town. The sorted result is saved in a new dataset named 'bytown'.
Copied!
proc sort data=account out=bytown;
by town company;
run;
1
2
PROC SORT
3
DATA=account out=bytown;
4
BY town company;
5
RUN;
6
3 Code Block
PROC PRINT
Explanation : This block uses the PROC PRINT procedure to generate a report displaying the contents of the 'bytown' dataset. It specifies the variables 'company', 'town', 'debt', and 'accountnumber' to be included in the report. Additionally, it defines two titles for the report: the first identifies 'Customers with Past-Due Accounts' and the second specifies that they are 'Listed Alphabetically within Town'.
Copied!
proc print data=bytown;
var company town debt accountnumber;
title 'Customers with Past-Due Accounts';
title2 'Listed Alphabetically within Town';
run;
1
PROC PRINTDATA=bytown;
2
3
var company town debt accountnumber;
4
5
title 'Customers with Past-Due Accounts';
6
title2 'Listed Alphabetically within Town';
7
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author - Anupama Rajaram
Program - We create a dataset called "data" and then sort it according to two variables : town, company
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.