Hi guys, suppose to have the following:
class1 class2 region weightclass sex
0 1 0 1 M
0 0 0 3 F
1 1 1 2 M
0 0 0 3 F
1 1 0 2 M
I would like to do proc freq of weightclass and sex by class1, class2 and region and then I would like to transpose. With a single variable I do the following:
proc sort data=mydata;
by class1 class2 region weightclass;
proc freq noprint data=mydata;
by class1 class2 region;
table weightclass/ out=freqs;
proc transpose data=freqs out=db(drop=_name_ _label_) prefix=var_;
by class1 class2 region;
id weightclass;
var count;
run;
How would it become if I add sex together with weightclass? I don't want the cross-product (weigtclass*sex) but only stratifications by class1 class2 region.
Thank you in advance
Edit: with only class1 (to simplify) desired output:
Region
class1
weightclass1
weightclass2
weightclass3
sexM
sexF
0
0
1
na
2
1
2
1
0
na
1
na
1
na
0
1
na
na
na
na
na
1
1
na
1
na
1
na
Note that, for weightclass3 as well as for sexF, 2 is because there are two records corresponding to region= 0 and class1 = 0
... View more