Introduction
Welcome to Edition 7 of Making SAS Accessible to Everyone. In the previous edition, we learned to prepare and validate data. Now, we explore how to analyze and report data in SAS using core procedures.
Whether preparing internal summaries, regulatory documentation, or executive dashboards, well-structured reporting is key. We’ll use PROC FREQ for categorical summaries, PROC MEANS for descriptive statistics, and introduce report customization using titles, labels, and grouped outputs. This edition emphasizes both analytic clarity and communication effectiveness.
1. Enhancing Output: Titles, Footnotes, and Labels
SAS reports often support decision-making, so context matters.
TITLE1 "Demographic Summary Report";
TITLE2 "Data collected from 2023 patient intake";
FOOTNOTE "Generated by 3 D Statistical Learning";
LABEL Age = "Patient Age"
Gender = "Biological Sex";
Tips:
- Use
TITLEandFOOTNOTEfor meaningful documentation. - Use
LABELfor more descriptive variable names in outputs. - Clear titles with
TITLE;and footnotes withFOOTNOTE;. - When printing data with labels, specify
LABELin your procedure:
PROC PRINT DATA=work.demographics LABEL;
RUN;
2. Frequency Tables with PROC FREQ
Use PROC FREQ to examine distribution and relationships between categorical variables:
PROC FREQ DATA=work.demographics;
TABLES Gender AgeGroup / NOCUM NOPERCENT;
RUN;
Common Options:
NOCUM: Suppress cumulative frequency and percentage.NOPERCENT: Hide column percentages.ORDER=FREQ: Sort results by descending frequency.NLEVELS: Displays the number of unique levels.OUT=: Save frequency results to a dataset.
Two-Way Table:
PROC FREQ DATA=work.demographics;
TABLES Gender*AgeGroup / NOCUM NOPERCENT;
RUN;
This cross-tabulates Gender by AgeGroup, ideal for comparing proportions across groups.
3. Summary Statistics with PROC MEANS
For numeric data summaries:
PROC MEANS DATA=work.clinical_summary N MEAN STD MIN MAX;
VAR Age Weight Height;
RUN;
This produces count, mean, standard deviation, min, and max.
Grouped Summaries with CLASS
PROC MEANS DATA=work.clinical_summary;
CLASS Gender;
VAR BMI;
RUN;
This produces statistics by Gender. You can group by multiple variables using multiple CLASS statements.
Exporting Results with OUTPUT
PROC MEANS DATA=work.clinical_summary;
CLASS Gender;
VAR BMI;
OUTPUT OUT=gender_summary MEAN(BMI)=Mean_BMI;
RUN;
This saves the mean BMI per Gender in a new dataset, useful for reports or joining with other data.
4. Grouped Reporting with PROC PRINT
To display grouped data:
PROC SORT DATA=work.clinical_summary;
BY Gender;
RUN;
PROC PRINT DATA=work.clinical_summary LABEL;
BY Gender;
RUN;
SAS automatically inserts headings when data is sorted and grouped by a BY variable.
This improves readability when printing reports.
5. Visual Summary with ODS Graphics
Enable visuals with ODS GRAPHICS ON:
ODS GRAPHICS ON;
PROC FREQ DATA=work.demographics;
TABLES AgeGroup / PLOT=FREQPLOT;
RUN;
ODS GRAPHICS OFF;
This creates a simple bar chart showing counts by age group. Note: ODS must be enabled before the procedure.
Conclusion
In Edition 7, we learned how to generate informative and interpretable reports:
- Use
TITLE,FOOTNOTE, andLABELto contextualize results - Use
PROC FREQfor categorical summaries and crosstabs - Use
PROC MEANSfor continuous variable statistics - Group reports using
BYvariables - Export summaries to new datasets
- Create visuals with
ODS GRAPHICS
These capabilities are foundational in both operational and strategic reporting.
What’s Next
In Edition 8, we’ll cover how to automate report generation and export outputs to Excel, PDF, and HTML using SAS’s Output Delivery System (ODS).
Stay curious and keep coding with 3 D Statistical Learning.
Special thanks to Dr. Dany Djeudeu for championing accessible and practical data science education in SAS.
We help businesses and researchers solve complex challenges by providing expert guidance in statistics, machine learning, and tailored education.
Our core services include:
– Statistical Consulting:
Comprehensive consulting tailored to your data-driven needs.
– Training and Coaching:
In-depth instruction in statistics, machine learning, and the use of statistical software such as SAS, R, and Python.
– Reproducible Data Analysis Pipelines:
Development of documented, reproducible workflows using SAS macros and customized R and Python code.
– Interactive Data Visualization and Web Applications:
Creation of dynamic visualizations and web apps with R (Shiny, Plotly), Python (Streamlit, Dash by Plotly), and SAS (SAS Viya, SAS Web Report Studio).
– Automated Reporting and Presentation:
Generation of automated reports and presentations using Markdown and Quarto.
– Scientific Data Analysis:
Advanced analytical support for scientific research projects.