Turn on suggestions

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

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Summarizing averages in PROC REPORTS

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 08-25-2022 06:12 AM
(219 views)

Hi SAS Community,

I am new to proc reports and would appreciate some guidance on my below need.

I have a data table:

```
data in;
input study $ subject device $ Yes_No Measure;
datalines;
A 1 a 1 348
A 1 a 0 1073
A 1 a 1 404
A 1 a 1 685
A 1 b 1 369
A 1 b 0 278
A 1 b 0 145
A 1 b 0 181
A 1 b 1 168
A 2 a 1 143
A 2 a 1 212
A 2 a 0 851
A 2 a 1 214
A 2 a 1 299
A 2 a 0 1201
A 2 b 0 406
A 2 b 0 124
A 2 b 1 953
A 2 b 0 169
A 2 b 0 783
A 3 a 1 153
A 3 a 1 151
A 3 a 0 217
A 3 a 0 313
A 3 a 0 864
A 4 b 1 5058
A 4 b 1 166
A 4 b 0 145
A 4 b 1 230
B 4 a 1 94
B 4 a 1 116
B 4 a 0 139
B 4 a 1 517
B 4 a 1 600
B 4 a 0 147
B 5 b 0 91
B 5 b 0 136
B 5 b 1 185
B 5 b 0 210
B 5 b 0 152
B 6 a 1 137
B 6 a 1 783
B 6 a 0 265
B 6 a 0 102
B 6 a 0 128
B 6 b 1 216
B 6 b 1 670
B 6 b 0 132
;
run;
```

The aim to compare the mean of measure across study. However, within each subject I first need calculate the mean of "measure" for each "device", and then use this to calculate the mean for each subject. This subject mean is then averaged across the study, and these are compared.

How do I print this final computed average (average for study, accounting for subject and device) to a proc report? I also want to repeat this for a number of other variables (i.e. not just measure, but Yes_No, measure1, measure2, measure3, ...).

Help would be great!

Thankyou

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The PROC GLM code I gave you previously will work.

Once you have an output data set from PROC GLM, you can then use that in PROC REPORT.

Alternative: use PROC SUMMARY twice to compute mean of means, then output from last PROC SUMMARY goes into PROC REPORT.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You might want to look at the output from this:

proc summary data=in ; class study device; var yes_no measure ; output out=summary mean= /autoname; run;

The _type_ variable indicates different levels of summaries done on both the variables (easy to add more variables to the VAR statement).

In this case:

_type_=0 is the summary across all studies and devices

_type_=1 is the summary across all studies for each device

_type_=2 is the summary for each study across all devices

_type_=3 is the summary for study/device combinations.

You could use the _type_ variable in Proc report to do further grouping or display control or even conditional text. But you haven't shown any idea of what your "proc report" output might be expected to look like.

Proc report is also one of the very few procedures that can use multilabel formats. So it might be possible with the proper format(s) for study or device to create the desired result from the data. But again, I have no idea what you actually want.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.