In this example,you use PROC MEANS to do much of the work that is often done by using extensive data manipulation in a DATA step,such as accumulating sums and counting missing values.You use several of the OUTPUT options in PROC MEANS to create an output summary data set that is then further formatted in a subsequent DATA step.This data set is then processed by PROC PRINT to produce the final report.
The fictitious data in this example were collected as part of a fund drive and then stored in SAS data set FUND.Each observation represents a letter mailed out to a resident asking for a contribution.The variables contained in FUND are NAME, TOWNSHIP, and AMOUNT.When the value for AMOUNT is missing, no donation was made by that person. Here is the SAS data set FUND:
You want to produce a report showing the following information for each township: the number of letters mailed, the total number of donations received,the total amount received, the average amount received per donation, and the average amount received per letter mailed.Sound difficult? Not if you use PROC MEANS.Here is the code:
ExampleOPTIONS LS*72 NONUMBER NODATE?
The statistics N, NMISS, and SUM in the PROC MEANS code provide you with some of the finished quantities you are looking for.You output N as RETURNED O and eventually label it as "NUMBER OF DONATIONS," © and output SUM as TOTAL and then label that as "TOTAL DONATION." NMISS is output as NOT_RETN. In the DATA step, you calculate the rest of the variables you need.
You add N (RETURNED) and NMISS (NOT_RETN) to get MAILED (total number of units mailed per township) © and label it "LETTERS MAILED"©. SUM (TOTAL) is divided by RETURNED (number of donations) © to get PER_RETN ("MEAN DONATION"),and by MAILED (number of units mailed) 0 to get PER_MAIL ("MEAN DONATION PER LETTER MAILED") to complete the data you need for the report.The LABEL option of PROC PRINT 0 instructs the system to use the labels connected to the variables for column headings instead of the variable names, and the DOUBLE option double spaces the report.The final listing from the program is shown here:
Output from Example- Producing a Formatted Summary Report
As you can see, this complete formatted summary report was generated with very little effort, using PROC MEANS as the centerpiece of the program.
SAS Programming Related Tutorials
|SASS (Syntactically Awesome Style sheets) Tutorial||R Programming language Tutorial|
SAS Programming Related Interview Questions
|Logistics Interview Questions||SAS Programming,SQL server Interview Questions|
|Clinical SAS Interview Questions||SASS (Syntactically Awesome Style sheets) Interview Questions|
|SQL Server Analysis Services (SSAS) Interview Questions||R Programming language Interview Questions|
|SAS DI Interview Questions||Advanced SAS Interview Questions|
|Base Sas Interview Questions||SAS Macro Interview Questions|
|Clinical Data Management Interview Questions|
Sas Programming Tutorial
Input And Infile
Set, Merge, And Update
Table Lookup Tools
Proc Means And Proc Uimivariate
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.