Published on :
Général INTERNAL_CREATION

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
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!
1DATA account;
2 INPUT Company $ 1-22 Debt 25-30 AccountNumber 33-36
3 Town $ 39-51;
4 DATALINES;
5Paul's Pizza 83.00 1019 Apex
6World Wide Electronics 119.95 1122 Garner
7Strickland Industries 657.22 1675 Morrisville
8Ice Cream Delight 299.98 2310 Holly Springs
9Watson Tabor Travel 37.95 3131 Apex
10Boyd & Sons Accounting 312.49 4762 Garner
11Bob's Beds 119.95 4998 Morrisville
12Tina's Pet Shop 37.95 5108 Apex
13Elway Piano and Organ 65.79 5217 Garner
14Tim's Burger Stand 119.95 6335 Holly Springs
15Peter's Auto Parts 65.79 7288 Apex
16Deluxe Hardware 467.12 8941 Garner
17Pauline's Antiques 302.05 9112 Morrisville
18Apex Catering 37.95 9923 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!
1 
2PROC SORT
3DATA=account out=bytown;
4BY town company;
5RUN;
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!
1PROC PRINT DATA=bytown;
2 
3var company town debt accountnumber;
4 
5 title 'Customers with Past-Due Accounts';
6 title2 'Listed Alphabetically within Town';
7RUN;
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