Transcription of How to make tables using SAS
1 How to generate tables using SASL iying (Lily) Wu Research Analyst Health Quality Council of SaskatchewanOutline Process to generate table Proc tablulateand examples Proc reportand examples A comparison of Proc tablulateand Proc reportGenerating table processStep1. Design the table Specification of classification variables and analysis variables, definition of dimensions of the table, Identification of desired statistics Step2. Generate the SAS codeStep3. Customize the , format, style, font, weightProc tablulateProcTabulate is used to build tabular reports containing descriptive information, including hierarchical relationships among procedure provides flexible report writing features such as: flexible table construction multiple dimensions use of labels and formatsProc tablulateThe general syntax PROC tabulate <option(s)>;BY <DESCENDING> variable-1 <.
2 <DESCENDING>variable-n> <NOTSORTED>;CLASS variable(s) </options>;CLASSLEV variable(s)/ STYLE=<style-element-name| <PARENT>> <[style-attribute-specification(s)] >;FREQ variable;KEYLABEL keyword-1='description-1'<..keyword-n='description-n'>;KEYWORD keyword(s)/ STYLE=<style-element-name|<PARENT>> <[style-attribute-specification(s)]>;TABLE <<page-expression, > row-expression,> column-expression< / table-option(s)>;VARanalysis-variable(s) </ options>;WEIGHT variable; Proc tablulate-Example 1proctabulatedata=asthma1 order=data;classregion;varnumber ;tablenumber*mean*region; run;Proc tablulate-Example 2proctabulatedata=asthma1 order=data;classregion;varnumber ;tableregion, number*mean ; run;Proc tablulate-Example 3proctabulatedata=asthma order=data;classregion time;varnumber;tabletime, region , number*mean ; run.
3 Portions of the table not shown .. Proc tablulate-Example 4proctabulatedata=asthma1 order=data;classregion time;varnumber ;tableregion, number*mean*time ; run; Proc tablulate-Example 5proctemplate; ;parent= ;styleheader/ font_size= font_face="arial";end;run;procformat;val ue$backf'Sun Country'= 'white''Five Hills'='CX93D6FF''Cypress'= 'white'"Regina Qu'Appelle "='CX93D6FF''Sunrise'= 'white''Saskatoon'='CX93D6FF''Saskatchew an'='beige';run;optionsnodatenonumberori entation=portrait pagesize=max;odspdffile="U:/SAS/ "style=sty3;Proc tablulate-Example 5title" Rate of Asthma related hospitalizations per 100,000 population and count of hospitalizations ";proctabulatedata= ;classregion reference time;classlevtime/style=[background=CX93 D6FF];classlevregion / style=[background=$backf.]
4 ];classlevreference / style=<parent>;varnumber ;table(region *reference)*[style=<parent>[font_weight=medium fontfamily="arial"foreground=black font_size= ]], time*number=' '*f= misstext=[label="*"] box=[label="Baseline as Oct 31, 2011"style=[font_weight=light fontfamily="arial"foreground=black font_size= ]]; keylabelsum=' ';keywordall/style=<parent> ;run;Proc reportThe report procedure combines features of the PRINT, MEANS, and tabulate procedures with features of the DATA step in a single report -writing tool that can produce a variety of reports. This procedure provides features as following: Generating table easily flexible to allow the calculation of a cumulative total and row change. Proc reportThe general syntax PROC report <option(s)>;BREAK location break-variable</ option(s)>;BY<DESCENDING> variable-1 <.
5 <DESCENDING> variable-n> <NOTSORTED>;COLUMN column-specification(s);COMPUTE location <target> </ STYLE=<style-element-name> <[style attribute -specification(s)]>>;LINE specification(s); .. select SAS language elements ..ENDCOMP;COMPUTE report -item </ type-specification>;CALL DEFINE (column-id, attribute-name , value); .. select SAS language elements ..ENDCOMP;DEFINE report -item / <usage> <attribute(s)> <option(s)> <justification> <COLOR=color> < column-header-1 <.. column-header-n >> <style>;FREQ variable;RBREAK location </ option(s)>;WEIGHT variable;Proc report -Example 1 Procreportdata=asthma1 nowd;columnregion number;defineregion /"Region"grouporder=data ;definenumber/"Mean"meanformat= ;run;Proc report -Example 2 Procreportdata=asthma1 nowd;columnregion number, time;defineregion /"Region"grouporder=data ;definetime/ acrossorder=data "Time";definenumber/ ""analysisformat= ; run;Proc report -Example 3 Procreportdata=asthma1 nowd;columnregion time number;defineregion /"Region"grouporder=data ;definetime/ order=data "Time";definenumber/ ""sumanalysisformat= ; breakafterregion/olskipsummarizesuppress ;rbreakafter/ dolskipsummarize;run.
6 Portions of the table not shown .. Proc report -Example 4 Procreportdata=asthma nowdstyle(header)=[background=CX93D6FF font_size= font_face="Arial"] style(column)=[font_size= ];columnregion reference number, time;defineregion /"Region"grouporder=data ;definereference/ "Reference"group;definetime/ acrossorder=data "Time";definenumber/ ""analysisformat= ;computeregion;ifregion=''thencalldefine (_row_,'STYLE','STYLE=[background=CX93D6 FF]'); ifregion='Saskatchewan'thencalldefine (_row_,'STYLE','STYLE=[background=beige] '); endcomp;run;Proc reportCompute blockOne of the unique features of the report procedure is the Compute Block. Unlike most other SAS procedures, PROC report has the ability to modify values within a column, to insert lines of text into the report , to create columns, and to control the content of a column.
7 Through compute blocks it is possible to use a number of SAS language elements, many of which can otherwise only be used in the DATA step. Compute<location> <report_item> </ options>;one or more SAS language elementsEndcomp;Proc report -Example 5 Procreportdata=asthma1 nowd;columnregion number;defineregion /"Region"grouporder=data ;definenumber/analysis"Mean"meanformat= ; computeafterregion;line'';endcomp;run;Pr oc report -Example 6 Procreportdata=asthma1 nowd;columnregion number predict;defineregion /"Region"grouporder=data ;definenumber/disply; definepredict/ computed"Predict"format= ;computepredict;predict=number* ;endcomp;run;.. portions of the table not shown .. Comparison of Proctabulate with Proc reportProctabulate Flexible table construction Supporting three-dimensional Providing both detail and summary reports.
8 Compute Carpenter, Carpenter's Complete Guide to the SAS report , SAS guide to report writing pass , PROC report : Doin it in L. Carpenter PROC report : Getting Started with the Primary L. Carpenter, PROC report : Compute Block Basics Part II Haworth, Anyone Can Learn PROC J. Winn, Introduction to PROC V. Bilenas, Making Sense of PROC tabulate (Updated for SAS9)Thank you!