BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
plf515
Lapis Lazuli | Level 10

Hello

 

I have a data set that has variables time (1 to 46); group (3 different groups) and alc (a numeric variable)

 

If I run

 

 

proc means data = ken.lsdalclong;
class time group;
var alc;
output out = ken.days mean = mean uclm = upper lclm = lower;
run;

 

 

then I get the mean, lcl and ucl of alc by time and group.  So far so good.

 

How can I get the differences between the means of the three groups by time?

 

That is, I want 46 values of (mean group 1 – mean group2) and 46 values of (mean group 1 – mean group3)?

 

Thanks

 

Peter

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

If you examine the output data set, you will see that you have the pieces that you need.  It is just a matter of extracting the right pieces and re-assembling them properly.  Here is a starting point:

 

proc transpose data=ken.days prefix=mean_group out=want;

id group;

var mean;

by time;

where _type_=3;

run;

 

Take a look first at KEN.DAYS to understand that the WHERE statement in PROC TRANSPOSE is selecting the proper observations.

 

Then take a look at the output data set WANT which will need a few more calculations, but has the data assembled in an easy-to-calculate form.

View solution in original post

1 REPLY 1
Astounding
PROC Star

If you examine the output data set, you will see that you have the pieces that you need.  It is just a matter of extracting the right pieces and re-assembling them properly.  Here is a starting point:

 

proc transpose data=ken.days prefix=mean_group out=want;

id group;

var mean;

by time;

where _type_=3;

run;

 

Take a look first at KEN.DAYS to understand that the WHERE statement in PROC TRANSPOSE is selecting the proper observations.

 

Then take a look at the output data set WANT which will need a few more calculations, but has the data assembled in an easy-to-calculate form.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1 reply
  • 941 views
  • 0 likes
  • 2 in conversation