BookmarkSubscribeRSS Feed
Pavan_SAS
SAS Employee
group stats drug-a drug-b
(n=50) (n=50)
a min 22 23
avg 12 34
group stats drug-a drug-b
(n=50) (n=50)
b min 82 63
avg 52 74

above result(table) in rtf format.

i want to repeat column names for each group, by using proc report.
how?
help me, by providing exact code.
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
Using a COMPUTED column, you can make a variable that will display on each row of your group. For example, REGION is the GROUP variable in the following report. It will have repetitious values suppressed on every report row for Asia and Canada.

However, the computed report item, DISPREG is a report column that will hold and display the value for each region. You can still make REGION a group variable, but then use the NOPRINT option so that it is not displayed on the report. But, DISPREG will be displayed on every line of the report, because you assign it the value of a temporary variable HOLDREG, which you grab from REGION on the first row of every group (when REGION has a value).

cynthia
[pre]
proc sort data=sashelp.shoes out=shoes;
where region in ('Asia', 'Canada');
by region;
run;

ods html file='seegroup.html' style=sasweb;
proc report data=shoes nowd;
column region dispreg product sales inventory;
define region/group noprint;
define dispreg/computed 'Region';
define product / group;
define sales/ sum;
define inventory/ sum;
compute before region;
length holdreg $40;
holdreg = region;
endcomp;
compute dispreg / character length=40;
dispreg=holdreg;
endcomp;
run;

ods html close;
[/pre]

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 838 views
  • 0 likes
  • 2 in conversation