Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating Summary Data Sets Ron Cody, Ed.D. Robert Wood Johnson Medical School.

Similar presentations


Presentation on theme: "Creating Summary Data Sets Ron Cody, Ed.D. Robert Wood Johnson Medical School."— Presentation transcript:

1 Creating Summary Data Sets Ron Cody, Ed.D. Robert Wood Johnson Medical School

2 Test data set (CLINIC) SUBJECT GENDERAGE_GROUPBLOOD_TYPEHRSBPDBP 1M1A M1B M2O M1A F2A F1B F2O F2O F1A F1B M1B M2B

3 PROC MEANS DATA=data_set_name NOPRINT; Is equivalent to PROC SUMMARY DATA=data_set_name; PROC MEANS vs. PROC SUMMARY

4 Creating a SUMMARY Data Set Containing MEANS PROC MEANS DATA=CLINIC NOPRINT; /**************************************** Equivalent to PROC SUMMARY DATA=CLINIC; *****************************************/ CLASS GENDER; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN=M_HR M_SBP M_DBP; RUN; Listing of data set OUT1 Obs GENDER _TYPE_ _FREQ_ M_HR M_SBP M_DBP F M

5 Using a BY statement Instead of a CLASS Statement PROC SORT DATA=CLINIC; BY GENDER; RUN; PROC MEANS DATA=CLINIC NOPRINT; BY GENDER; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN=M_HR M_SBP M_DBP; RUN; Listing of data set OUT1 Obs GENDER _TYPE_ _FREQ_ M_HR M_SBP M_DBP 1 F M

6 Creating a SUMMARY Data Set Containing MEANS Broken Down by GENDER and AGE_GROUP PROC MEANS DATA=CLINIC NOPRINT; CLASS GENDER AGE_GROUP; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN=M_HR M_SBP M_DBP; RUN; AGE_ GENDER GROUP _TYPE_ _FREQ_ M_HR M_SBP M_DBP F M F F M M

7 Explaining the _TYPE_ Variable Class VariablesRepresentation GENDERAGE_GROUPBinaryDecimal CLASS GENDER AGE_GROUP;

8 Demonstrating the NWAY Option PROC MEANS DATA=CLINIC NOPRINT NWAY; CLASS GENDER AGE_GROUP; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN=M_HR M_SBP M_DBP; RUN; AGE_ GENDER GROUP _TYPE_ _FREQ_ M_HR M_SBP M_DBP F F M M

9 Outputting More than One Statistic PROC MEANS DATA=CLINIC NOPRINT; CLASS GENDER; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN =M_HR M_SBP M_DBP N =N_HR N_SBP N_DBP MAX =MAX_HR MAX_SBP MAX_DBP MEDIAN =MED_HR MED_SBP MED_DBP; RUN; GENDER _TYPE_ _FREQ_ M_HR M_SBP M_DBP N_HR N_SBP F M N_DBP MAX_HR MAX_SBP MAX_DBP MED_HR MED_SBP MED_DBP

10 Partial List of Some Available Statistics KeywordDescription________________________________ MEANMean NNumber of non-missing values NMISSNumber of missing values MINSmallest non-missing value MAX Largest value MEDIANMedian RANGERange - difference between the minimum and maximum values Q125 th percentile Q375 th percentile QRANGEInterquartile range (difference between 25 th and 75 th percentile) STDStandard deviation STDERRStandard error UCLMUpper bound of the 95% confidence interval LCLMLower bound of the 95% confidence interval

11 Demonstrating the AUTONAME OUTPUT option PROC MEANS DATA=CLINIC NOPRINT; CLASS GENDER; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN = N = MAX = MEDIAN = / AUTONAME; RUN; GENDER _TYPE_ _FREQ_ HR_Mean SBP_Mean DBP_Mean HR_N SBP_N F M SBP_ DBP_ DBP_N HR_Max SBP_Max DBP_Max HR_Median Median Median

12 Another Way of Naming Output Variables PROC MEANS DATA=CLINIC NOPRINT NWAY; CLASS GENDER AGE_GROUP; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN=; RUN; Listing of Data Set OUT1 AGE_ GENDER GROUP _TYPE_ _FREQ_ HR SBP DBP F F M M

13 Dropping Unneeded Variables in the Output Dataset PROC MEANS DATA=CLINIC NOPRINT NWAY; CLASS GENDER AGE_GROUP; VAR HR SBP DBP; OUTPUT OUT=OUT1(DROP= _:) MEAN=M_HR M_SBP M_DBP; RUN; Listing of Data Set OUT1 AGE_ GENDER GROUP M_HR M_SBP M_DBP F F M M

14 Demonstrating the CHARTYPE Procedure Option PROC MEANS DATA=CLINIC NOPRINT CHARTYPE; CLASS GENDER AGE_GROUP; VAR HR SBP DBP; OUTPUT OUT=OUT1 MEAN=M_HR M_SBP M_DBP; RUN; Demonstrating CHARTYPE Option AGE_ GENDER GROUP _TYPE_ _FREQ_ M_HR M_SBP M_DBP F M F F M M

15 Demonstrating the CHARTYPE Procedure Option PROC PRINT DATA=OUT1 NOOBS; TITLE "Demonstrating CHARTYPE Option"; WHERE _TYPE_ EQ "10"; RUN; Demonstrating CHARTYPE Option AGE_ GENDER GROUP _TYPE_ _FREQ_ M_HR M_SBP M_DBP F M

16 Another Way to Name Variables (instead of using a VAR statement ) PROC MEANS DATA=CLINIC NOPRINT; CLASS GENDER; ***VAR STATEMENT OPTIONAL; OUTPUT OUT=OUT1 MEAN(HR) =M_HR N(HR SBP DBP) =N_HR N_SBP N_DBP MAX(SBP) =MAX_SBP MEDIAN(SBP DBP) =MED_SBP MED_DBP; RUN; GENDER _TYPE_ _FREQ_ M_HR N_HR N_SBP N_DBP MAX_SBP MED_SBP MED_DBP F M

17 Multi-way Breakdowns Using a TYPES Statement PROC MEANS DATA=CLINIC NOPRINT CHARTYPE; CLASS GENDER AGE_GROUP BLOOD_TYPE; VAR HR SBP DBP; TYPES GENDER AGE_GROUP*GENDER BLOOD_TYPE*GENDER; OUTPUT OUT=OUT1 MEAN=M_HR M_SBP M_DBP; RUN; AGE_ BLOOD_ GENDER GROUP TYPE _TYPE_ _FREQ_ M_HR M_SBP M_DBP F M F. A F. B F. O M. A M. B M. O F F M M

18 Using the _TYPE_ Values to Create Multiple Data Sets DATA GENDER AGE_BY_GENDER BLOOD_BY_GENDER; SET OUT1; IF _TYPE_ = "100" THEN OUTPUT GENDER; ELSE IF _TYPE_ = "110" THEN OUTPUT AGE_BY_GENDER; RUN; Listing of Data Set GENDER AGE_ BLOOD_ GENDER GROUP TYPE _TYPE_ _FREQ_ M_HR M_SBP M_DBP F M Listing of Data Set AGE_BY_GENDER AGE_ BLOOD_ GENDER GROUP TYPE _TYPE_ _FREQ_ M_HR M_SBP M_DBP F F M M

19 Examples of TYPES Statements TYPES A A*C D*C; TYPES A*(B C D); TYPES () A A*C*D;

20 Using PROC FREQ to Count Frequencies PROC FREQ DATA=CLINIC NOPRINT; TABLES AGE_GROUP / OUT=NUMBER; RUN; Listing of Data Set NUMBER AGE_ GROUP COUNT PERCENT

21 Renaming the COUNT Variable PROC FREQ DATA=CLINIC NOPRINT; TABLES AGE_GROUP / OUT=NUMBER(RENAME=(COUNT=N_AGE) DROP=PERCENT); RUN; Listing of Data Set NUMBER AGE_ GROUP N_AGE

22 Using PROC MEANS to Count Frequencies PROC MEANS DATA=CLINIC NOPRINT NWAY; CLASS AGE_GROUP; VAR HR; /* ANY NUMERIC VARIABLE */ OUTPUT OUT=COUNTS(RENAME=(_FREQ_ = N_AGE) DROP=_TYPE_ DUMMY) N=DUMMY; RUN; Listing of Data Set COUNTS AGE_ GROUP N_AGE

23 Using PROC FREQ to Count Frequencies in a Two-way Table PROC FREQ DATA=CLINIC NOPRINT; TABLES GENDER*BLOOD_TYPE / OUT=FREQOUT(DROP=PERCENT RENAME=(COUNT=NUMBER)); RUN; Listing of Data Set FREQOUT BLOOD_ GENDER TYPE NUMBER F A 2 F B 2 F O 2 M A 2 M B 3 M O 1

24 Using PROC FREQ to Output More than One Data Set PROC FREQ DATA=CLINIC NOPRINT; TABLES AGE_GROUP / OUT=OUT1; TABLES GENDER / OUT=OUT2; TABLES GENDER*AGE_GROUP / OUT=OUT3; RUN; Listing of Data Set OUT1 AGE_GROUP COUNT PERCENT Listing of Data Set OUT2 GENDER COUNT PERCENT F 6 50 M Listing of Data Set OUT3 GENDER AGE_GROUP COUNT PERCENT F F M M


Download ppt "Creating Summary Data Sets Ron Cody, Ed.D. Robert Wood Johnson Medical School."

Similar presentations


Ads by Google