BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kc2
Quartz | Level 8 Kc2
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Kc2
Quartz | Level 8 Kc2
Quartz | Level 8

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

2 REPLIES 2
Kc2
Quartz | Level 8 Kc2
Quartz | Level 8

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.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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