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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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