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

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;
bhr-q
Quartz | Level 8
Thanks so much, it was helpful

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 207 views
  • 2 likes
  • 3 in conversation