Creating Reports in Different Formats
Using ODS (Output Delivery System):
ODS can output reports in different format files like HTML, PDF, XML etc.
ODS can output reports to different systems like SAS O/P window, file, printer etc.
Example.
Sample SAS Code
ODS HTML file = ‘fully qualified output file path’;
PROC PRINT data = dataset_name;
Run;
ODS HTML close;
When PROC print enclosed in ODS statement it gives output in corresponding format as specified in the ODS statement.
SUMMARY REPORTS:
Following are the summary reports procedures
PROC FREQ – Frequency counts
PROC MEANS – simple statistics
PROC TABULATE – flexible summary reports
PROC REPORT – flexible detailed or summary
PROC FREQ:
PROC FREQ data = data_set_name NLEVELS;
tables var1 var2 _ALL_ / NOPRINT;
title ‘Title String’;
run;
NLEVELS – gives the number of distinct values for given variable in the tables statement
TABLES – By default PROC FREQ calculates frequency reports for all variables in data set which in real life is certainly not required to avoid this we use tables statement with list of necessary variable names.
NOPRINT – is used to avoid the printing of report
_ALL_ - combination of _ALL_ and NOPRINT gives number of distinct values for each variable without printing report.
In general PROC FREQ calculates frequency, cumulative frequency, percentage, cumulative percentage etc.
At the bottom of the report it also prints frequency of missing values
PROC FREQ : CROSSLIST
PROC FREQ data = data_set_name;
table jobcode * salary / CROSSLIST NOCUM;
run;
When * is given in between 2 variables of the table statement; it gives CROSS tabular summary against each other.
CROSSLIST – this option prints the report in listing format
NOCUM – if we don’t want cumulative columns in the report.
PROC MEANS :
PROC MEANS data – data_set_name MAXDEC;
var var1 var2;
class varname;
title ‘Title String’;
run;
VAR – restricts the number of variables for which statistics needs to be generated
CLASS – When this option is used PROC MEANS does the group by on the variables specified in CLASS statement and then calculates the statistics.
MAXDEC – controls the number of decimal places
PROC MEANS by default identifies numeric variables in the dataset and calculates simple numeric statistics upon those. These statistics are
N – Non missing values
MEAN- mean / average
STD – standard deviation
MIN – minimum value
MAX – maximum value
We can specify other statistics if needed like RANGE, MEDIAN, SUM, NMISS etc.