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

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!

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.

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
  • 634 views
  • 0 likes
  • 3 in conversation