Top Banner
Niraj J. Pandya, Element Technologies Inc., NJ
14

Niraj J. Pandya, Element Technologies Inc., NJ. Summarize all possible combinations of class level variables even if few categories are altogether missing.

Jan 12, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

Niraj J. Pandya, Element Technologies Inc., NJ

Page 2: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

Summarize all possible combinations of class level variables even if few categories are altogether missing in the database.

It is difficult to get SAS to summarize what isn’t there, e.g., how can a procedure directly count data points that do not exist in the data?

Techniques/options with some SAS Procedures to summarize missing categories in the report and fill with zero

2

Page 3: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

3

Page 4: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

4

Proc Format;

Value range 1='Low'2='Normal'3='High';

Value sex 1 = 'Male' 2 = 'Female'

;Run;

Page 5: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

/* Hard coded dummy dataset in the format same as expected in final output */

Data Dummy(drop = i j);

Do i = 1 to 3;Do j = 1 to 2;

SEX = j;RANGE = i;

N = 0; MEAN = .; MEDIAN = .; STD = .; MIN = .; MAX = .;

Output;End;

End;

Run;

5

/* Create a dataset containing summary statistics */

Proc Means Data = HDL noprint; Class SEX RANGE; Var LBRSLT; Output out = Stat(keep = SEX RANGE N Mean Median Std Min Max) N = N Mean = Mean Median = Median Std = Std Min = Min Max = Max;

Run;

Page 6: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

Data Stat; Merge Dummy Stat; By SEX RANGE; Format SEX sex. RANGE range.; /* Apply previously defined formats */

Run;

Proc Print noobs;Run;

6

Page 7: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

Proc Means Data = HDL noprint completetypes; Format SEX sex. RANGE range.; Class SEX RANGE/preloadfmt; Var LBRSLT;

Output out = Stat(keep = SEX RANGE N Mean Median Std Min Max) N = N Mean = Mean Median = Median Std = Std Min = Min Max = Max ;Run;

7

Page 8: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

Proc Tabulate Data = HDL; Format SEX sex. RANGE range.;

Class SEX RANGE/preloadfmt; Var LBRSLT; Table SEX='SEX'*RANGE='RANGE', LBRSLT=''*N='N' LBRSLT=''*MEAN='MEAN' LBRSLT=''*MEDIAN='MEDIAN' LBRSLT=''*STD='STD' LBRSLT=''*MIN='MIN' LBRSLT=''*MAX='MAX' / printmiss;Run;

8

Page 9: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

/* Create Dummy variables for each expected statistics */

Data HDL1; Set HDL; N=LBRSLT; MEAN=LBRSLT; MEDIAN=LBRSLT; STD=LBRSLT; MIN=LBRSLT; MAX=LBRSLT;

Run;

9

Proc Report Data=hdl1 completerows nowd; Format SEX sex. RANGE range.; Column SEX RANGE N MEAN MEDIAN STD MIN MAX; Define SEX / order = internal group preloadfmt; Define RANGE / order = internal group preloadfmt; Define N / analysis n; Define MEAN / analysis mean; Define MEDIAN / analysis median; Define STD / analysis std; Define MIN / analysis min; Define MAX / analysis max;

Run;

Page 10: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

10

Page 11: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

11

Reduction of unnecessary data manipulation and hard coding

PRELOADFMT: Taking care of user defined formats

Code efficient and less time consuming

Page 12: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are registered trademarks or trademarks of their respective companies.

12

Page 13: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

Name: NIRAJ J. PANDYA Phone: 201-936-5826 E-mail: [email protected]

13

Page 14: Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.

14