Example: stock market

Basics of Proc Tabulate - SAS: Analytics, Artificial ...

Anky LaiCancer Surveillance & Outcomes (CSO)Population OncologyBC Cancer AgencyBasics of Proc TabulateIntroduction What is Proc Tabulate ? A procedure that displays descriptive statistics in tabular format But aren t there other procsthat do the same ;varage height;run;procmeansdata= ;classsex;varage height; run; I want summary stats on students ages and heights, overall and by gender. proctabulatedata= ;classsex;varage height;table(age height)*(N MEAN STD MIN MAX), SEX ALL; run;Introduction Why should you use it? Payoff is in the output Saves a lot of time Reduces errors Easy to format tablesOutline PROC Tabulate Basics Customize tables Export tablesProc Tabulate Basics Basic syntax:(1)proctabulatedata=dataset <options>;(2)classvariable(s) </option(s)>; variables used in PROC FREQ*And/Or*varvariable(s) </option(s)>; variables used in PROC MEANS(3)table<page>,<row>,<column> </table-option(s)>; run;Table Statement All variables listed in the TABLE statement must be listed in CLASS or VAR More than one TABLE statement can be used The order of the variables in the statement will be the same as the output tableTable Statement Create 1, 2, or

1-Dimensional Tables Use ‘ALL’ to calculate overall statistics Treat as a classification variable proc tabulate data=sashelp.cars ; class TYPE; var MSRP ; table TYPE ALL (TYPE ALL)*MSRP*MEAN; run; Output:

Tags:

  Dimensional

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Basics of Proc Tabulate - SAS: Analytics, Artificial ...

1 Anky LaiCancer Surveillance & Outcomes (CSO)Population OncologyBC Cancer AgencyBasics of Proc TabulateIntroduction What is Proc Tabulate ? A procedure that displays descriptive statistics in tabular format But aren t there other procsthat do the same ;varage height;run;procmeansdata= ;classsex;varage height; run; I want summary stats on students ages and heights, overall and by gender. proctabulatedata= ;classsex;varage height;table(age height)*(N MEAN STD MIN MAX), SEX ALL; run;Introduction Why should you use it? Payoff is in the output Saves a lot of time Reduces errors Easy to format tablesOutline PROC Tabulate Basics Customize tables Export tablesProc Tabulate Basics Basic syntax:(1)proctabulatedata=dataset <options>;(2)classvariable(s) </option(s)>; variables used in PROC FREQ*And/Or*varvariable(s) </option(s)>; variables used in PROC MEANS(3)table<page>,<row>,<column> </table-option(s)>; run;Table Statement All variables listed in the TABLE statement must be listed in CLASS or VAR More than one TABLE statement can be used The order of the variables in the statement will be the same as the output tableTable Statement Create 1, 2, or 3 dimensional tables: 1 dimensional (no commas): Syntax: table<column dimension> / <options>.

2 2 dimensional (1 comma): Syntax: table<row dimension>,<column dimension>/<options>; 3 dimensional (2 commas): Syntax: table<page>,<row>,<column>/<options>;Table Statement Operators to use in each dimension: 1) Asterisk (*) adding a classification variable adding another statistic2) Parentheses ( ) group elements and simplify coding and output3) space places output for each element immediately after the output of the ) All calculate row or column totalsDataset Dataset: (N=428) Set up dataset as you would have it for PROC FREQ or PROC MEANS Examples done in SAS Tables Basic exampleproctabulatedata= ;varMSRP; classTYPE DRIVETRAIN; tableMSRP;tableTYPE DRIVETRAIN; run;Output: 1- dimensional Tables Adding a classification variable Syntax: <variable name> *<class variable>proctabulatedata= ;varMSRP;classTYPE DRIVETRAIN;tableMSRP*TYPEMSRP*DRIVETRAIN ; run;Output: 1- dimensional Tables Adding another statistic Syntax: <variable name>*statistic-keyword1- dimensional Tables1) Add similar code to Table statementproctabulatedata= ;classTYPE;varMSRP ;tableMSRP*TYPE*sumMSRP*TYPE*mean;run;Ou tput:2) Use parenthesesproctabulatedata= ;classTYPE;varMSRP ;table MSRP*TYPE*(sum mean); tableMSRP*(sum mean)*TYPE ;run;Output:1- dimensional Tables Use ALL to calculate overall statistics Treat as a classification variableproctabulatedata= ;classTYPE; varMSRP ;tableTYPE ALL (TYPE ALL)*MSRP*MEAN; run;Output:Customizing 2-D Tableproctabulatedata=.

3 ClassDRIVETRAIN ORIGIN TYPE ;varMSRP HORSEPOWER;tableALL (DRIVETRAIN TYPE)*(N COLPCTN) (MSRP TYPE*HORSEPOWER)*(MEAN STD), (ORIGIN ALL); run;Customizing 2-D Table Print missing dataproctabulatedata=cars missing;classDRIVETRAIN ORIGIN TYPE ;varMSRP HORSEPOWER;tableALL (DRIVETRAIN TYPE)*(N COLPCTN) (MSRP TYPE*HORSEPOWER)*(MEAN STD), (ORIGIN ALL); run;Customizing 2-D Table Right align levels and statistic labelsproctabulatedata= ;classDRIVETRAIN ORIGIN TYPE ;classlevDRIVETRAIN TYPE/s=[just=right];varMSRP HORSEPOWER;tableALL (DRIVETRAIN TYPE)*(N ={s=[just=right]} COLPCTN ={s=[just=right]}) (MSRP TYPE*HORSEPOWER)*(MEAN={s=[just=right]}) STD={s=[just=right]} ), (ORIGIN ALL); run;Customizing 2-D Table Edit headings and statistics keywordsproctabulatedata= ;classDRIVETRAIN ORIGIN TYPE ;classlevDRIVETRAIN TYPE / s=[just=right];keylabelCOLPCTN='%';varMS RP HORSEPOWER;tableALL (DRIVETRAIN ='Drive Type'TYPE)*(N={s=[just=right]} COLPCTN={s=[just=right]}) (MSRP TYPE*HORSEPOWER)*(MEAN={s=[just=right]} STD={s=[just=right]}), (ORIGIN =''ALL ='Total') / box='Car Stats'; run;Customizing 2-D Table Edit values (change formats, replace missing values)proctabulatedata= ;classDRIVETRAIN ORIGIN TYPE ;classlevDRIVETRAIN TYPE / s=[just=right];keylabelCOLPCTN='%';varMS RP HORSEPOWER;tableALL (DRIVETRAIN='Drive Type'TYPE)*(N={s=[just=right]} COLPCTN={s=[just=right]}*f= ) (MSRP TYPE*HORSEPOWER)*(MEAN={s=[just=right]}* f= {s=[just=right]}), (ORIGIN=''ALL='Total') / box='Car Stats'misstext='0'; run.

4 Customizing 2-D Table Edit order of categories procformat;value$ drivefmt (notsorted)'Front'= 'FRONT''Rear'= BACK''All'= 'ALL';run;proctabulatedata= ;classORIGIN TYPE ;classDRIVETRAIN/preloadfmtorder=data;cl asslevDRIVETRAIN TYPE / s=[just=right];varMSRP HORSEPOWER;tableALL (DRIVETRAIN='Drive Type'TYPE)*(N COLPCTN='%'*f= ) (MSRP TYPE*HORSEPOWER)*(MEAN*f= ), (ORIGIN=''ALL='Total')/misstext='0'box=' Cars Stats'; formatDRIVETRAIN $drivefmt.; run;Exporting to C:\My Documents\ 'style=statisticaloptions(ABSOLUTE_COLUM N_WIDTH="10,10,6,6,6,6,6"EMBEDDED_TITLES ='yes'SHEET_NAME='CARS');title'Descripti ve Statistics for CARS dataset';proctabulatedata= ;classORIGIN TYPE ;classDRIVETRAIN/preloadfmtorder=data;cl asslevDRIVETRAIN TYPE / s=[just=right];keylabelCOLPCTN='%';varMS RP HORSEPOWER;tableALL (DRIVETRAIN='Drive Type'TYPE)*(N={s=[just=right]} COLPCTN={s=[just=right]}*f= ) (MSRP TYPE*HORSEPOWER)*(MEAN={s=[just=right]}* f= {s=[just=right]}), (ORIGIN=''ALL='Total')/box='Car Stats'misstext='0'; formatDRIVETRAIN $drivefmt.

5 ;run; ;Exporting to C:\My Documents\ 'style=statisticaloptions(ABSOLUTE_COLUM N_WIDTH="10,10,6,6,6,6,6"EMBEDDED_TITLES ='yes'SHEET_NAME='CARS');title'Descripti ve Statistics for CARS dataset';proctabulatedata= ;classORIGIN TYPE ;classDRIVETRAIN/preloadfmtorder=data;cl asslevDRIVETRAIN TYPE / s=[just=right];keylabelCOLPCTN='%';varMS RP HORSEPOWER;tableALL (DRIVETRAIN='Drive Type'TYPE)*(N={s=[just=right]} COLPCTN={s=[just=right]}*f= ) (MSRP TYPE*HORSEPOWER)*(MEAN={s=[just=right]}* f= {s=[just=right]}), (ORIGIN=''ALL='Total')/box='Car Stats'misstext='0'; formatDRIVETRAIN $drivefmt.;run; ;procformat;value$originfmt'USA'= 'U:\My Documents\BCCA\Presentations\VANSUG2013\ '; 'Orange 0-200= 'Blue 201-1000= 'Purple 1001-high = 'Red'; run;odshtmlfile= 'U:\My Documents\ ';proctabulatedata= [foreground=numfmt.]

6 ];classTYPE / s=[background=pink foreground=blue];classORIGIN / s=[background=pink foreground=blue];classDRIVETRAIN/preload fmtorder=datas=[background=pink foreground=blue];classlevDRIVETRAIN TYPE / s=[just=right background=purple foreground=white];classlevORIGIN / S=[Vjust=T postimage=$originfmt.];keylabelCOLPCTN=' %';varMSRP HORSEPOWER;tableALL (DRIVETRAIN='Drive Type'TYPE)*(N={s=[just=right color=green]} COLPCTN={s=[just=right color=red background=orange]}*f= ) (MSRP TYPE*HORSEPOWER)*(MEAN={s=[just=right]}* f= {s=[just=right]}), (ORIGIN=''ALL='Total')/box='Car Stats'misstext='0'; formatDRIVETRAIN $drivefmt.;run;odshtmlclose;References


Related search queries