BookmarkSubscribeRSS Feed
Etoo12121
Obsidian | Level 7

Hi,

How can I get the below proc report output to show the statistics vertically? After every visit, I want to show all the statistics going down.

 

Etoo12121_1-1638219615976.png

Here is the code I currently have:

proc report data=Test;
columns visit Groups, adlscore_: ;
define visit / 'Visit' group ;
define adlscore_N / ANALYSIS "N" Spacing=2;
define adlscore_Mean / analysis "Mean" format=6.2 Spacing=2;
define ADLSCORE_StdDev / analysis "SD" format=6.2 Spacing=2;
define ADLSCORE_LCLM / analysis "L95%CI" format=6.2 Spacing=2;
define ADLSCORE_UCLM / analysis "U95%CI" format=6.2 Spacing=2;
define ADLSCORE_Median /analysis "Median" format=6.2 Spacing=2;
define ADLSCORE_Min / analysis "Min" format=6.2 Spacing=2;
define ADLSCORE_Max / analysis "Max" format=6.2;
define groups / across  ;

endcomp;

run;

 

Here is how the output should look

Etoo12121_3-1638220188176.png

 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

This request seems to go against the grain of PROC REPORT.

 

You would need to re-arrange your data set and create a variable that takes on values N MEAN MIN MAX etc. So on the rows where this variable has the value N, you have the statistic n; on the rows with MEAN you have the statistic mean; and so on.

--
Paige Miller
PaigeMiller
Diamond | Level 26

Adding: you can in the wide layout that you show, have all the N together (three columns, one each for group 0, 1 and 2) and then have all the means together (three columns, one each for group 0, 1 and 2), and so on. This isn't hard to do in PROC REPORT.

--
Paige Miller
Etoo12121
Obsidian | Level 7

Not sure I follow

Reeza
Super User

PROC TABULATE seems like it would work here if you use the raw data rather than summarized data?

Something like this:

 

proc tabulate data=test;
class visits groups;
var adlscore;
table visit * adlscore*(N MEAN STD LCLM UCLM MEDIAN MIN MAX), groups;
run;

@Etoo12121 wrote:

Hi,

How can I get the below proc report output to show the statistics vertically? After every visit, I want to show all the statistics going down.

 

Etoo12121_1-1638219615976.png

Here is the code I currently have:

proc report data=Test;
columns visit Groups, adlscore_: ;
define visit / 'Visit' group ;
define adlscore_N / ANALYSIS "N" Spacing=2;
define adlscore_Mean / analysis "Mean" format=6.2 Spacing=2;
define ADLSCORE_StdDev / analysis "SD" format=6.2 Spacing=2;
define ADLSCORE_LCLM / analysis "L95%CI" format=6.2 Spacing=2;
define ADLSCORE_UCLM / analysis "U95%CI" format=6.2 Spacing=2;
define ADLSCORE_Median /analysis "Median" format=6.2 Spacing=2;
define ADLSCORE_Min / analysis "Min" format=6.2 Spacing=2;
define ADLSCORE_Max / analysis "Max" format=6.2;
define groups / across  ;

endcomp;

run;

 

Here is how the output should look

Etoo12121_3-1638220188176.png

 


 

Etoo12121
Obsidian | Level 7
Proc tabulate would be great but I have table shells I must follow. The final output has 4 weeks in the Visit column so the table bleeds out onto another page when I output into rtf using ODS. I must have the entire table on one page so using tabulate isn't my best option. Anyway I can calculate the same descriptive stats in proc report if I use the raw data?

Something like this:
proc report data=Test;
columns visit Groups, adlscore_: ;
define visit / 'Visit' group ;
define adlscore / ANALYSIS N Spacing=2;
define adlscore / analysis Mean format=6.2 Spacing=2;
define adlscore / analysis Std format=6.2 Spacing=2;
define adlscore / analysis CLM format=6.2 Spacing=2;
define adlscore / analysis Median format=6.2 Spacing=2;
define adlscore / analysis Min format=6.2 Spacing=2;
define adlscore / analysis Max format=6.2;
define groups / across ;

endcomp;
run;

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