BookmarkSubscribeRSS Feed
KevinQin
Obsidian | Level 7
Hi,
Take sashelp.class as example, how can I create a report as follows:

Sex: F
Name Height
Alice 56.5
Barbara 65.3
Carol 62.8
Jane 59.8
Janet 62.5
Joyce 51.3
Judy 64.3
Louise 56.3
Mary 66.5

Sex: M
Name Height
Alfred 69
Henry 63.5
James 57.3
Jeffrey 62.5
John 59
Philip 72
Robert 64.8
Ronald 67
Thomas 57.5
William 66.5

For now, I always do it using TITLE statement with #BYVAL. I am wondering if there exist a smarter method.

Any idea will be appreciated.
3 REPLIES 3
deleted_user
Not applicable
Hi Kevin,

You can try this:

proc sort data=sashelp.class out=class;
by sex;
run;

data class;
set class class class class class class class class class class class class;
run;

proc report data=class nowindows;
column sex name height;

define sex /order noprint;

break after sex/page;

compute before _page_/left;
line "Sex: " sex $8.;
endcomp;
run;
data_null__
Jade | Level 19
Smarter? I don't know. Different, sort of.

I just realized this is the same as the post by John JW sorry 'bout 'dat.

[pre]
ods rft file='class02.rtf';
ods rtf startpage=never;
proc report nowd list data=sashelp.class;
column sex name age height weight;
define _all_ / display;
define sex / order noprint;
break before sex / page;
compute before _page_;
line 'Sex:' sex $1.;
endcomp;
run;
ods rtf close;
[/pre] Pay attentention.


Message was edited by: data _null_;
KevinQin
Obsidian | Level 7
Thank you.
It is excat what I want. 🙂

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1864 views
  • 0 likes
  • 3 in conversation