A proc report question

Reply
N/A
Posts: 0

A proc report question

I'm a new programmer using proc report for listing and i have two questions:

1, I need to know how to concatenate variables with a line skip;
for example: var1:city; var2: country
I concatenate var1||","||var2.

i want the output show like "
san diego,
usa
"

instead of "san diego, usa "

2, when grouping, i want the value of group variable show on the first line of the next page.

for example:
orignian:
001 xxx
.... xxx
(page break)
.... xxx
i want:
001 xxx
..... xxx
(page break)
001 xxx

I think it's common requirements i just can't figure out myself. thanks!
Super Contributor
Super Contributor
Posts: 3,174

Re: A proc report question

share what code you have - it will help.
SAS Super FREQ
Posts: 8,716

Re: A proc report question

Hi:
#1) In ODS RTF, PDF and HTML, you can insert a "line feed" or what you call a line skip into a character string, by using ODS ESCAPECHAR, as shown in the program below:
[pre]
ods escapechar='^';

data class;
length newvar $50;
set sashelp.class;
newvar = 'Name: '||name||'^n Age: '||put(age,2.0)||
'^n Gender: '||sex;
run;

ods listing;
ods html file='class_linebr.html' style=sasweb;
ods rtf file='class_linebr.rtf' ;
ods pdf file='class_linebr.pdf';

proc print data=class;
title 'Put a line break';
var newvar name age height sex;
run;
ods _all_ close;
[/pre]

If the ESCAPE character is set to '^' (as it is above), then ESCAPECHAR + n represents a line feed. However, this line feed character is NOT recognized as a line feed by the LISTING window. So in the LISTING window, you will still see the ^n (which you do not see in the HTML, RTF or PDF files.)

#2) When you use ODS RTF, PDF in SAS 9.1.3, it is very hard to get the repeat of a group variable at the top of the page when the output breaks across pages, as described in this Tech Support note:
http://support.sas.com/kb/7/887.html

A lot of pharmaceutical companies get around this issue by writing their reports to use BY group processing so each group starts on a separate page, or, soemtimes, they write their own RTF strings instead of using ODS, or, sometimes by post-processing the RTF file, or, sometimes, by figuring out how many observations will fit on a page and then creating a "page counter" variable to use with PROC REPORT (which is the workaround described in the Tech Support Note).

This behavior is not a problem in SAS 9.2, when you use TAGSETS.RTF, but unless you are on SAS 9.2, you have to deal with this issue or work around it somehow..

Here are some other PROC REPORT tutorials that you might find helpful:
http://www2.sas.com/proceedings/forum2008/031-2008.pdf
http://www2.sas.com/proceedings/forum2008/188-2008.pdf

It is also possible that your coworkers have already dealt with this issue in their standard set of report programs that they use for clinical trials. Since most report programs must be tested and validated for a clinical trial, the chances are very good that you will find your company already has a preferred workaround for this issue.

cynthia
N/A
Posts: 0

Re: A proc report question

Thank you for the very helpful answers cynthia!
Mark
N/A
Posts: 0

Re: A proc report question

try this....

while concatenating also insert '~', and in proc report use split='~' and flow oprion in the define statement....for example

proc report data= aa nowd split = '~' ;
column newpid;
define newpid / width = 30 flow;
run;
N/A
Posts: 0

Re: A proc report question

and the o/p will be some thing like


newpid
USA,
002608001
USA,
002608002
USA,
003208015
USA,
003308022
Ask a Question
Discussion stats
  • 5 replies
  • 481 views
  • 0 likes
  • 3 in conversation