turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How do I get differences between groups over time ...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-18-2018 11:57 AM

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

Accepted Solutions

Solution

02-18-2018
12:42 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to plf515

02-18-2018 12:17 PM

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.

All Replies

Solution

02-18-2018
12:42 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to plf515

02-18-2018 12:17 PM

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.