Difference between CLASS and By processing in SAS STAT Procs? -
i wondering if there major difference between using class or statements in sas stat procs. take proc means example. suppose have 2 group/categorical variables, x1 , x2. want compute summary statistics variable (x3) each level combination of x1 , x2.
example, using class x1 x2
gives me summary stats x3 @ x2=1 @ x1=1 , summary stats x3 @ x2=2 @ x1=1, , on. below example output.
x1=1 x2=1 x3 mean std x2=2 x3 mean std x1=2 x2=1 x3 mean std ...
if use by x1 x2
get
x1=1 x2=1 x3 mean std (new page) x1=1 x2=2 x3 mean std (new page) ....
if use class x1
, by x2
get
x1=1 x2=1 x3 mean std x2=2 x3 mean std x1=2 x2=1 x3 mean std x2=2 x3 mean std ......
this sample data
x1 x2 x3 1 1 3 1 1 4 1 2 6 1 2 2 2 1 5 2 1 1 2 2 2 2 2 6 3 1 10 3 1 2 3 2 1 3 2 8
the best can tell, there no difference in output, except manner in displayed. example may simplistic show differences.
beyond bob noted (the sorting requirement), important, there differences in how percentages calculated. in proc tabulate, example, class variable must on page, row, or column dimension, while supersedes that; pctn
, pctsum
work across class variables (as opposed rowpctn
wetc.), important because pctn
, pctsum
can used denominator definitions, while rowpctn
etc cannot.
some stat procs evaluate differences between class groups, while variables again supersede - proc ttest example compares values between different values of class variables, while groups create different strata inside comparisons performed.
finally, encourage use them correctly in terms of showing intend them show. variables should denote separate strata, analysis performed on each strata independently. class variables should denote different groupings of data in same stratum. helpful creating self documenting code, if careful consistent, easier read code , understand data.
Comments
Post a Comment