DATA Step, Macro, Functions and more

calculating a percentage based on different counts at each time point.

Accepted Solution Solved
Reply
Contributor Kc2
Contributor
Posts: 31
Accepted Solution

calculating a percentage based on different counts at each time point.

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


Accepted Solutions
Solution
‎08-09-2016 05:47 AM
Contributor Kc2
Contributor
Posts: 31

Re: calculating a percentage based on different counts at each time point.

[ Edited ]

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.

View solution in original post


All Replies
Super User
Super User
Posts: 7,392

Re: calculating a percentage based on different counts at each time point.

Solution
‎08-09-2016 05:47 AM
Contributor Kc2
Contributor
Posts: 31

Re: calculating a percentage based on different counts at each time point.

[ Edited ]

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 193 views
  • 0 likes
  • 2 in conversation