BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhr-q
Pyrite | Level 9

Hello all,

Many thanks for helping me to convert the first design to the second design.

 

Id           B       w     g

1             8        .        .

1             7        .        .

1             .        6        .       

1             .        5        .

1             .        .         4 

1             .        .         5

2           4        .          .

2           3        .          . 

2           .         6          .

2           .         2         .

2          .          .          8

2           .        .           4

.

.

.

 

Second design: the number here  is the mean number of each event (B,w,g ) for each id_recoded

Id           B        w     g

1            7.5     5.5    4.5  

2           3.5       4        6

.

.

.

                                        

 

Thank you in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User
Proc summary data=have nway;
   class id;
   var b w g;
   output out=want (drop= _: ) mean=;
run;

Looks likely.

 

The NWAY means that only the highest level of the _type_ variable goes into the output.

The drop is because otherwise two additional variables, _type_, indicating combinations of the CLASS variables, and _freq_ would appear.

Mean= used this way with this procedure says "name the statistic mean with the original name of the variable". You could rename the results if desired.

View solution in original post

3 REPLIES 3
ballardw
Super User
Proc summary data=have nway;
   class id;
   var b w g;
   output out=want (drop= _: ) mean=;
run;

Looks likely.

 

The NWAY means that only the highest level of the _type_ variable goes into the output.

The drop is because otherwise two additional variables, _type_, indicating combinations of the CLASS variables, and _freq_ would appear.

Mean= used this way with this procedure says "name the statistic mean with the original name of the variable". You could rename the results if desired.

data_null__
Jade | Level 19

 

data test;
   input Id B w g;
   cards;
1             8        .        .
1             7        .        .
1             .        6        .       
1             .        5        .
1             .        .         4 
1             .        .         5
2           4        .          .
2           3        .          . 
2           .         6          .
2           .         2         .
2          .          .          8
2           .        .           4
;;;;
   run;
proc print;
   run;
proc summary data=test nway;
   class id;
   output out=means mean(b w g)=;
   run;
proc print;
   run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register 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
  • 3 replies
  • 933 views
  • 2 likes
  • 3 in conversation