Hello,
I need some help with setting up multipage spanning for a very long variable in one of my columns. Currrently is just runs below the table and disappears. The next page starts another record. I am new to Proc Report, so I am baffled. Using PC Sas 9.4.
Here is a sample fo my code:
proc report data = datafile style(header) = [background = white] nowd;
ods rtf file= myoutput.rtf style = styles_sm_try;
column et_1 et_2 et_3 ;
define et_1 / style (column) = [cellwidth = 3];
define et_2 / style(column) = [cellwidth = 2];
define et_3 / style(column) = [celwidth = 4];
run;
The problem is et_3 runs off the page (it's very long). I just need it to continue populating the column on the next page, and subsequent pages if needed until it's done. How do I do this?
Thank you!
I think you want the FLOW option.
Define et_3 / FLOW <rest of options>;
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473627.htm
Why have a very long variable in the first place? Process your data before you get to the proc report, split that long column out as you want to see it. We do this a lot with comment fields that can be quite long, what we do is split to a given length say 40, moving to the previous blank or other delimiter, then for each block of maximum 40 create a new record with a sequence identifier:
e.g.
COMMENT
This is a very long comment line which I need to split to be able to get it into a given column width.
Becomes:
SEQ COMMENT
1 This is a very long comment line which
2 I need to split to be able to get it into
3 a given column width.
You can of course arrange this any way you like, with indents or elipses (...), and you can even not have the separate rows and just insert ^{newline} statements - assumes you are using RTF and escapechar=^.
At the end of the day it is far better for you, the owner of the data to decide on what the output should look like than letting some generic software guess for you.
Thank you. This is a table I am making. One more question. I have inserted "~n" as newline option within the variable where needed... is the indent command "~indent" ? (I am using the ~ as my escape char).
Thank so much!
Just addressing the ~{newline} question. The ~{newline} inline function is newer and is preferred over old-school ~n. Here's the doc about ODS inline functions.
Well, if your talking about indent then this article should help:
http://support.sas.com/kb/42/377.html
If you want to indent yourself, then you could use spaces - preferred as tabs are different between renderers (RTF is just markup text which gets rendered by programs). You could of course put RTF tagset directly into the output:
"~rtf{\tab\your text}"
Hi:
The code below produced this example of doing an indent in RTF using 2 different style attribute methods:
Then there are several examples of how to make the text in a cell wrap by altering the cellwidth. Since the OP did not post any data, I made some fake data, but I varied the width for the variable et_3 so that the impact could be observed at varying widths.
cynthia
** all the code;
**make some fake data;
data makelong;
length et_3 $254;
et_1 = 'aaa';
et_2 = 'bbbbbbbbbbbbbbbbbbbbbb';
tmp = 'xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx ';
et_3 = tmp || tmp || tmp || tmp ||tmp || tmp;
output;
output;
et_1 = 'ccc';
et_2 = 'ddddddddddd';
et_3 = translate(et_3,'w', 'x');
output;
output;
et_1 = 'eee';
et_2 = 'fffffffffff';
et_3 = translate(et_3,'f', 'w');
output;
output;
et_1 = 'ggg';
et_2 = 'hhhhhhhhhh';
et_3 = translate(et_3,'y', 'f');
output;
output;
run;
options orientation=portrait topmargin=.25in bottommargin=.25in leftmargin=.25in rightmargin=.25in;
ods escapechar='^';
ods rtf file='c:\temp\wrapit.rtf';
proc report data=makelong nowd;
title '1) Let ODS decide the default Width for et_3';
column et_1 et_2 et_3;
define et_1 /order;
define et_2 /order;
define et_3 / display;
run;
proc report data=makelong nowd;
title '2) Use CELLWIDTH attribute at 2 inches';
column et_1 et_2 et_3;
define et_1 /order;
define et_2 /order;
define et_3 / display
style(column)={cellwidth=2in};
run;
proc report data=makelong nowd;
title '3) Use CELLWIDTH attribute at 4 inches';
column et_1 et_2 et_3;
define et_1 /order;
define et_2 /order;
define et_3 / display
style(column)={cellwidth=4in};
run;
proc report data=makelong nowd;
title '4a) Use CELLWIDTH attribute at 6 inches';
column et_1 et_2 et_3;
define et_1 /order;
define et_2 /order;
define et_3 / display
style(column)={cellwidth=6in};
run;
proc report data=makelong nowd;
title '4b) Use CELLWIDTH attribute at 6 inches with smaller font for et_ variables';
column et_1 et_2 et_3;
define et_1 /order style(column)={cellwidth=.75in font_size=12pt};
define et_2 /order style(column)={cellwidth=.75in font_size=10pt};
define et_3 / display
style(column)={cellwidth=6in font_size=8pt};
run;
ods rtf close;title;
ods rtf file='c:\temp\show_indent.rtf';
proc report data=sashelp.class;
where substr(name,1,1) le 'J';
title '5) How to indent';
column name age sex height weight;
define name / style(column)={just=l cellwidth=1in};
define sex / style(column)={just=l cellwidth=1in};
compute name;
if name in ('Barbara', 'Janet') then do;
call define(_col_,'style','style={indent=20 background=lightgreen}');
end;
endcomp;
compute sex;
if name in ('Barbara', 'Janet') then do;
call define(_col_,'style','style={leftmargin=.25in background=lightgreen}');
end;
endcomp;
run;
ods rtf close;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.