Help using Base SAS procedures

PROC REPORT: Repeating Group and Order Variables on Each Row

Reply
Contributor
Posts: 61

PROC REPORT: Repeating Group and Order Variables on Each Row

I have a need to include the group variable on each row of a report, because one of my end users is confused with the present format. I tried reading about this issue in Carpenter's Complete Guide on the SAS Report Pocedure, and I understand his example using the compute block to assign the formated value of group variable to a temporary variable, then moving that temporary variable to a report item. The trouble is applying that technique to some inherited code that is more complex than the example in the book.

Is there another "work-around" option for this problem?
Super User
Posts: 3,115

Re: PROC REPORT: Repeating Group and Order Variables on Each Row

One possibility is to summarise and order your data first using the MEANS/SUMMARY and SORT procedures then define your ORDER and GROUP variables as DISPLAY instead.
SAS Super FREQ
Posts: 8,745

Re: PROC REPORT: Repeating Group and Order Variables on Each Row

Hi:
If you are dealing with inherited code and you do not want to try to fiddle with it, you do not have a lot of options. The technique shown in Carpenter's book is essentially the technique you will need to use. Another possibility is to pre-summarize the data, as suggested. Yet another option would be to make a "fake" variable in a DATA step program, which would be a duplication of the group or order variable, but you would use if for DISPLAY -- there's an example of this technique shown below.

If you don't want to pre-summarize the data or fiddle with the existing code or use the DATA step technique, then another possible option is to open a track with Tech Support. They will be able to look at your existing code and your data and help you figure out the best way/place to change the existing program.

To open a track with Tech Support, go to:
http://support.sas.com/ctx/supportform/createForm

cynthia
[pre]
** make DISPLAY_AGE and DISPLAY_SEX in a program instead of a ;
** COMPUTE BLOCK.;

data class;
set sashelp.class;
where age in (12, 13);
display_age = age;
display_sex = sex;
run;

ods listing close;
ods html file='show_other_alt.html' style=sasweb;

proc report data=class nowd;
title '1) Default ORDER Usage Behavior';
column age sex name height weight;
define age /order;
define sex / order;
define name / order;
define height /display;
define weight / display;
compute after age;
line ' ';
endcomp;
run;

proc report data=class nowd;
title '2a) Using Display_Age and Display_Sex Variables';
column age sex display_age display_sex name height weight;
define age /order;
define sex / order;
define display_age / display 'Age';
define display_sex / display 'Sex';
define name / order;
define height /display;
define weight / display;
compute after age;
line ' ';
endcomp;
run;

proc report data=class nowd;
title '2b) Using Display_Age and Display_Sex Variables with NOPRINT';
column age sex display_age display_sex name height weight;
define age /order noprint;
define sex / order noprint;
define display_age / display 'Age';
define display_sex / display 'Sex';
define name / order;
define height /display;
define weight / display;
compute after age;
line ' ';
endcomp;
run;

ods html close;

[/pre]
Super User
Posts: 9,691

Re: PROC REPORT: Repeating Group and Order Variables on Each Row

Ask a Question
Discussion stats
  • 3 replies
  • 1468 views
  • 0 likes
  • 4 in conversation