BookmarkSubscribeRSS Feed
EdB
Calcite | Level 5 EdB
Calcite | Level 5
Hello all:

I'm trying to develop reports that display various descriptive statistics over time. There are too many time intervals (columns in these reports) to put all the stats together, so I'd like to stack them.

Example - for each measurement and grouping, I'd like to display

Statistic Interval1 Interval2 Interval3 .....
N
Median
Q1
Q3

The formats of each cell depend on the measure and the statistic. With Proc Report I can put the statistics on the same row but it's not a good display with many intervals.

I can think of several ways to do this: with data _null_ and put statements, by transforming data into text and using proc prints, or by sending it to excel for where I could use macros for formatting. I'm sure there are many other ways, but I think there are many reasons to use proc report or tabulate if it's possible. The results will end up in a PDF so going to excel adds a layer of complexity that I'd rather avoid.

My questions: Is this possible in Report or Tabulate? Are there other techniques to try? Has a task like this been solved - e.g. in a user group presentation or a SAS paper or tutorial or somewhere else?

Thanks
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Recommend looking at PROC TRANSPOSE for creating column-oriented information for your "interval" values. Consider searching the SAS Support http://support.sas.com/ website for topic-oriented technical papers on the subject.

Scott Barry
SBBWorks, Inc.
Cynthia_sas
SAS Super FREQ
Hi:
Even though this code is using SASHELP.CARS, imagine that where I have MAKE going across the columns, you would have your Interval variable. And then where I have MSRP and INVOICE going down the rows, you would have the variables for which you wanted descriptive statistics.

This might be easier to do with PROC TABULATE than PROC REPORT. Frequently when folks generate this kind of report with PROC REPORT, they "preprocess" the data with PROC MEANS first to get the descriptive statistics and -then- they use PROC PRINT or PROC REPORT on the output from PROC MEANS.

Anyway, here's some PROC TAB code to try. Note the use of the format modifier to give the N statistic a different format from the other statistics.

cynthia
[pre]

ods listing close;
ods rtf file='c:\temp\desc_stats.rtf'
style=journal;

proc tabulate data=sashelp.cars f=comma12.2;
title '1) With Proc Tabulate';
where make in ('Acura', 'GMC', 'Buick');
class make;
var msrp invoice;
table msrp*(n*f=comma6. min max mean std)
invoice*(n*f=comma6. min max mean std),
make all;
run;

ods rtf close;
[/pre]
EdB
Calcite | Level 5 EdB
Calcite | Level 5
Cynthia
Thanks - this is exactly what I was hoping for!

I'm reporting medians and quartiles for the totals and medians for subgroup results and Report is working well for the subgroups displays, but this will be perfect for the summaries.

Thanks again
Ed

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
  • 3 replies
  • 788 views
  • 0 likes
  • 3 in conversation