BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
share what code you have - it will help.
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
Thank you for the very helpful answers cynthia!
Mark
deleted_user
Not applicable
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;
deleted_user
Not applicable
and the o/p will be some thing like


newpid
USA,
002608001
USA,
002608002
USA,
003208015
USA,
003308022

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 5 replies
  • 1016 views
  • 0 likes
  • 3 in conversation