Hello,
I am doing a summary by category of response and by visit for a group of people.
proc means data=all noprint;
by visit cat ;
var aval;
output out=final_cat n=n mean=mean min=min ;
run;
proc means data=all noprint;
by visit cat under;
var aval;
output out=final_under n=ns ;
run;
I then do a proc transpose and set the 2 datasets together;
proc transpose data=final_cat out=Tr_cat;
by visit;
var n mean min;
id cat;
run;
Proc sort data= final_under ; by visit under ; run;
proc transpose data=final_under out=Tr_under;
by visit under;
var ns;
id cat;
run;
data final;
tr_cat tr_under;
by visit;
set
run;
I get :
category 1 category 2 category3
Day1 N 18 19 6
Mean 0.5 0.6 1.34
Min 0.1 0.5 0.2
under 12 17 (%) 17 (%) 5(%)
over 12 1(%) 2(%) 1(%)
Day4 N 8 3 32
Mean 0.4 0.35 0.73
Min 0.1 0.2 0.1
under 12 7 (%) 3 (%) 23(%)
over 12 1 (%) 0 (%) 9(%)
Day8 N 3 1 39
Mean
Min
under 12 3(%) 1(%) 29(%)
over 12 0 (%) 0(%) 10(%)
I need to calculate the percentage in red based on the count of people at each visit.Ex for Day 1, in category 1, under 12 it should be (7/8)*100.
How can I do it?
Thanks
KC
Thanks but I resolved my problem.
I cretaed an intermediate merge data step in which I merge the two datastep, calculate the percentage and then do the transpose.
Please post some test data so that we can run code:
Thanks but I resolved my problem.
I cretaed an intermediate merge data step in which I merge the two datastep, calculate the percentage and then do the transpose.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.