Hello,
I have 200 character length observation and I wanted to insert escape character every 30 characters so I can break the text into multiple lines in the report to look better. I am not sure how to get it. Could someone please help me?
Thanks,
Svm
I am using PDF Reeza.
The proper character(s) may vary depending on the destination of the output and possibly the procedure used. So, which output destination are you using and what code are you using to create the report?
Example data may help as well.
Note that "inserting" characters may fail at a point because adding characters may make the length exceed the defined length of the variable an so would result in truncating (removing) the right most characters of your original variable.
Here is the code.
ods listing close;
ods escapechar ="~" ;
ods pdf file="H:\Summary report.pdf" bookmarkgen=no;
proc report data=_all_report headline headskip nowd ;
title1 "AD Summary";
column title count pg;
define title / " " display style(column)={width=3.5in};
define count / " " display style(column)={width=6.5in};
define pg / order noprint;
BREAK AFTER pg/page;
run;
ods pdf close;
SAS should wrap the text for you automatically in a PDF file.
I made a sample dataset for your report and ran it via SAS/Studio that automatically produces PDF output file.
data have;
pg=1;
legnth title $200 ;
title=repeat('1234567890',19);
count=1;
run;
proc report data=have headline headskip nowd ;
title1 "AD Summary";
column title count pg;
define title / " " display style(column)={width=3.5in};
define count / " " display style(column)={width=6.5in};
define pg / order noprint;
BREAK AFTER pg/page;
run;
If the text has spaces in it then they will be used help make the splits clearer.
@svmtho wrote:
Here is the code.
ods listing close;
ods escapechar ="~" ;
ods pdf file="H:\Summary report.pdf" bookmarkgen=no;
proc report data=_all_report headline headskip nowd ;
title1 "AD Summary";
column title count pg;
define title / " " display style(column)={width=3.5in};
define count / " " display style(column)={width=6.5in};
define pg / order noprint;
BREAK AFTER pg/page;
run;
ods pdf close;
Now WHICH variable is the one you want to insert characters into?
I want to insert the characters in count variable. The issue I was seeing is the text is getting over the border line.
Are there no internal blanks in your text? That's how your image looks. Would it be ok to change all occurrences of a comma with a comma followed by a blank? Then the automatic text wrap in PDF might be more likely to avoid writing over the cell boundary. You wouldn't have to put escape characters at fixed intervals, allowing more appealing line wraps for proportional fonts.
I tired to insert space after comma but it wasn't' successful. PFA
I am creating the list using sql into separated by ", " and resolving it in a data step.
Post your code. If you had a space in the separator it would not occur.
@svmtho wrote:
I am creating the list using sql into separated by ", " and resolving it in a data step.
here is the sample code and data which is kind of similar to my data.
proc sql noprint;
select key into:abc separated by ", " from sashelp.aacomp;
quit;
data _All_report;
title="This is a test";
count="&abc.";
run;
ods listing close;
ods escapechar ="~" ;
ods pdf file="H:\Summary.pdf" bookmarkgen=no;
proc report data=_all_report headline headskip nowd ;
title1 "Summary";
column title count ;
define title / " " display style(column)={width=3.5in};
define count / " " display style(column)={width=6.5in};
run;
ods pdf close;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.