BookmarkSubscribeRSS Feed
chandler
Fluorite | Level 6
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?
3 REPLIES 3
SASKiwi
PROC Star
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.
Cynthia_sas
SAS Super FREQ
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]

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!

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.

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
  • 3973 views
  • 0 likes
  • 4 in conversation