The SAS Output Delivery System and reporting techniques

PROC REPORT: Character variable under ACROSS

Reply
Regular Contributor
Posts: 187

PROC REPORT: Character variable under ACROSS

Hi,

There was another post on this forum concerning this problem but I didn't get the info from it that I wanted, so I try again. :-)

See the result of the following code:
[PRE]
proc report data=sashelp.class nowindows;
columns age sex,(name height);
define age /group;
define sex /across;
define name /display;
define height / analysis;
run;
[/PRE]

[PRE]
Sex
F M
Age Name Height Name Height
11 Joyce 51.3 Thomas 57.5
12 Jane 59.8 .
Louise 56.3 James 57.3
. John 59
. Robert 64.8
13 Alice 56.5 .
Barbara 65.3 Jeffrey 62.5
14 Carol 62.8 .
Judy 64.3 Alfred 69
. Henry 63.5
15 Janet 62.5 .
Mary 66.5 Ronald 67
. William 66.5
16 . Philip 72
[/PRE]

Why is proc report skipping the lines? And what is the algorithm?

The result I'm looking for is like this but with the empty cells shifted up per AGE.

-Bart

Message was edited by: bheinsius

Message was edited by: bheinsius Added code results


Message was edited by: bheinsius
Super Contributor
Super Contributor
Posts: 3,174

Re: PROC REPORT: Character variable under ACROSS

Posted in reply to bheinsius
If you are sharing your SAS code (it's unclear, at least to me), suggest you also share a sample of "See the result of the following code". You can easily paste an example (or code one up) in your reply.

Scott Barry
SBBWorks, Inc.
Super Contributor
Posts: 359

Re: PROC REPORT: Character variable under ACROSS

This has always been one of my pet peaves about proc report. It cannot roll up values unless they are numeric and you use a sum etc.
Respected Advisor
Posts: 3,799

Re: PROC REPORT: Character variable under ACROSS

You will have to roll your own.

[pre]
proc sort data=sashelp.class out=class;
by age sex name;
run;
data class;
set class;
by age sex name;
if first.sex then index=0;
index + 1;
run;
proc report data=class list nowindows;
columns age index sex,(name height);
define age / group;
define index / group noprint;
define sex / across;
define name / display;
define height / sum;
break after age / skip;
run;
[/pre]
Regular Contributor
Posts: 187

Re: PROC REPORT: Character variable under ACROSS

Posted in reply to data_null__
That's a great solution for me data _null_, thanks!
-Bart
Regular Contributor
Posts: 187

Re: PROC REPORT: Character variable under ACROSS

I tried pasting the results of my code but formatting was messed up.
How can I do that?

-Bart
Respected Advisor
Posts: 3,799

Re: PROC REPORT: Character variable under ACROSS

Posted in reply to bheinsius
[pre]
left square bracket pre right square bracket
left square bracket /pre right square bracket
[ pre ]
code or output goes here
[ /pre ]
like above with with no spaces
[/pre]
SAS Super FREQ
Posts: 8,868

Re: PROC REPORT: Character variable under ACROSS

Posted in reply to bheinsius
Hi:
This forum posting shows how to use the [ and ] brackets with "pre" and "/pre" in order to preserve the indenting in code and logs that you post.
http://support.sas.com/forums/thread.jspa?messageID=27609毙

If you were writing HTML (which I know that not everybody does), HTML has <pre> and </pre> tags to "preserve" code formatting on web pages.

But, since the forum application is, itself, an HTML based application, you can't use HTML tags in your posts. So you have to use the same concept but with [ instead of < and with ] instead of > ... if you read the post above, it explains everything.

cynthia
Ask a Question
Discussion stats
  • 7 replies
  • 334 views
  • 0 likes
  • 5 in conversation