1 / 31

SAS PROC REPORT PROC TABULATE

SAS PROC REPORT PROC TABULATE. Computing for Research I January 27, 2014. PROC REPORT. Proc Report Intro. Similar to Proc Print, with more control over output appearance and format Produces detail reports (data listings) and summary reports. Proc Report Syntax Basics.

noreen
Download Presentation

SAS PROC REPORT PROC TABULATE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SASPROC REPORTPROC TABULATE Computing for Research I January 27, 2014

  2. PROC REPORT

  3. Proc Report Intro • Similar to Proc Print, with more control over output appearance and format • Produces detail reports (data listings) and summary reports

  4. Proc Report Syntax Basics PROC REPORT data=dataset <options>; COLUMN var1 var2 var3; DEFINE var1 / <options>; DEFINE var2 / <options>; RUN;

  5. Proc Report Statement • DATA= input data set • NOWD/NOWINDOWS Option - non-interactive mode • Additional Options - control layout of the report • COLWIDTH= • MISSING • SPLIT=‘character’ • SPANROWS (for ODS only) • STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]> (for ODS only)

  6. Other Statements Column Statement - describes the arrangement of columns and column headers that span >1 column Define Statement • Variable Appearance (format, label, justify) • Variable Usage DISPLAY – default for character variables ANALYSIS – default for numeric variables ORDER – determines row order ORDER=FORMATTED | INTERNAL | DATA | FREQ GROUP – consolidates unique values of GROUP variables into one row Rbreak Statement - produces a default summary at the beginning or end of a report or at the beginning or end of each BY group.

  7. Vital Signs Dataset • SubjectID (47 subjects) • VisitID (1-16), Visit Nm (Baseline, Day 1 – Day 15) • SBP, DBP, Heart Rate, Central Venous Pressure • 1 record per subject per visit

  8. Proc Report Code: Example 1 title'Baseline and Day 1 Blood Pressure' ; procreportdata=vitals nowdsplit='*'; where visitid in (1,2) and 1020 le subjectid le 1029; columns subjectid visitnm ('Blood*Pressure' SBP DBP); define subjectid / 'Subject'order; define visitnm / 'Visit' ; define SBP / 'Systolic'format=8.center; define DBP / 'Diastolic'format=8.center; run;

  9. Proc Report Output: Example 1

  10. Proc Print Comparison: Example 1 procsortdata=vitals; by subjectid; run; procprintdata=vitals labelnoobs; where visitid in (1,2) and 1020 le subjectid le 1029; var subjectid visitnm SBP DBP; run;

  11. Proc Report Code: Example 2 odsrtf; title'Average Blood Pressure by Visit'; procreportdata=vitals nowdsplit='*' style(header)=[fontsize=14pt textalign=center foreground=white background=black]; columns visitnm ('Average*Blood Pressure' SBP DBP); define visitnm / 'Visit'grouporder=data; define SBP / 'Systolic'format=8.centermean; define DBP / 'Diastolic'format=8.centermean; rbreakafter /summarize; run; odsrtfclose;

  12. Proc Report Output: Example 2

  13. Proc Means Comparison: Example 2 odsrtf; title'Average Blood Pressure by Visit'; procmeansdata=vitals mean; class visitnm; var SBP DBP; run; odsrtfclose;

  14. Proc Report Resources • SAS Documentation • Learning Proc Report • http://www2.sas.com/proceedings/forum2008/170-2008.pdf • Proc Report Advanced Tutorial • http://www2.sas.com/proceedings/sugi28/015-28.pdf

  15. PROC TABULATE

  16. Proc Tabulate Intro • Similar to Proc Means and Proc Freq, in tabular format • Creates summary reports with descriptive statistics

  17. Proc Tabulate Syntax Basics PROC TABULATE data=dataset; CLASSclassification variables; VARanalysis variables; TABLEpage dimension, row dimension, column dimension / <options>; RUN;

  18. Class and Var Statements Class Statement • identifies the class variables (character or numeric) • determines the categories that Proc Tabulate uses to calculate statistics • Missing Option - if not included, observations with any missing class variable values are excluded from the table Var Statement • Identifies numeric variables to use as analysis variables.

  19. Table Statement • Required for procedure • Describes the table to create • Format: page variables, row variables, column variables • Can include variable names, keyword statistics, and operators • Options • PRINTMISS • MISSTEXT= • BOX=

  20. Table Statement Operators • Comma – starts a new dimension • Blank – concatenates elements • Asterisk – creates categories from the combination of values of the class variables and calculates appropriate statistics if class and analysis variables are crossed • Parentheses – groups elements, associates operator with each element in the group

  21. Table Statement Statistic Keywords N NMISS PCTN COLPCTN ROWPCTN MEAN STD MIN MAX MEDIAN Q1 Q3 many more…

  22. Other Statements • KEYLABEL – labels a statistic keyword • KEYWORD – specifies a style element for keyword headings • CLASSLEV – specifies a style element for class variable level value headings

  23. Proc Tabulate Code: Example 1 proctabulatedata=vitals; where visitid in (1,2) and 1020 le subjectid le 1029; class subjectid visitnm; table all subjectid, (visitnm='Visits')*(n pctn='%') / box=[label='Subjects x Visits'] misstext='MISSING'printmiss; run;

  24. Proc Tabulate Output: Example 1

  25. Example 1: Proc Freq Comparison procfreqdata=vitals; where visitid in (1,2) and 1020 le subjectid le 1029; table subjectid*visitnm /norownocol; run;

  26. Proc Tabulate Code: Example 2 title'Average Blood Pressure Across Baseline and Day 1'; proctabulatedata=vitals; where visitid in (1,2) and 1020 le subjectid le 1029; class subjectid ; var SBP DBP; table all subjectid, (SBP DBP)*(n mean*f=8.1 std*f=8.1); keylabelstd='SD'; run;

  27. Proc Tabulate Output: Example 2

  28. Example 2: Proc Means Comparison procmeansdata=vitals meanstd; where visitid in (1,2) and 1020 le subjectid le 1029; class subjectid; var SBP DBP; run;

  29. Proc Tabulate Resources • SAS Documentation • Proc Tabulate Introduction http://www.sascommunity.org/mwiki/images/4/49/Proc_Tabulate_how_to_-_version_2.0.pdf • Using Style Elements in the REPORT and TABULATE Procedures http://support.sas.com/resources/papers/stylesinprocs.pdf

  30. Reporting Data • Plan the layout • Summary statistics, analysis output or data listings? • Content of columns/rows? • Order of columns/rows? • Font • Use a report writing tool

  31. QUESTIONS?

More Related