Hello,
I am using proc report to write out to an xlsx workbook. There are 5 footnotes that are required at the bottom left of the worksheet. All 5 lines require a different format (background color, font color, font style). The / style statement does not work.. I am just getting errors.
compute after population ;
length text1 text2 text3 text4 text5 $100;
if population in ('SCO','NHMCR') then do;
text1 = '* = STARS Clinical Outcomes Measure';
text2 = '* CDC Poor Control is an inverse measure - lower is better';
text3 = 'Dark yellow indicates current rate is better than MY 2022 final rate.';
text4 = 'Bold measures - triple weighted';
text5 = 'TRC - 2 Star weights - Average of submeasure and Med Rec';
end;
else if population in ('MH','NH') then do;
text1 = '*-Triple weighted measure';
text2 = 'Withhold measure';
text3 = '';
text4 = '';
text5 = '';
end;
else do;
text1 = ' ';
text2 = ' ';
text3 = ' ';
text4 = ' ';
text5 = ' ';
end;
/** each of these line statements need a different format **/
line text1 $char100. / style = [&FlagStyle just=left];
line text2 $char100.;
line text3 $char100.;
line text4 $char100.;
line text5 $char100.;
endcomp;
Data, in the form of a working data step.
Complete rest of the Procedure. It is entirely too easy for use to make a guess about where something is in a report body and be incorrect. Resulting in solutions that will not actually work.
List of the properties for which "line". If we don't know what to create when how can we get any sort of solution?
And if you are going to place information in Macro variables then include the definitions of ALL the macro variables to be used and which line they are to be used with.
And best would be to provide an example of what the result should look like given the example data set.
ods excel file='c:\temp\temp.xlsx';
ods escapechar='~';
proc report data=sashelp.class nowd;
columns sex age weight;
define sex/group;
define age/display;
compute after sex/style={just=l};
line '~{style [foreground=green fontsize=12]xxxxxxxxxx} ~n~{style [foreground=blue fontweight=bold]yyyyyyyyy}';
endcomp;
run;
ods excel close;
Hi, Another way to do this conditionally with multiple LINE statements, shown below using just 3 groups from SASHELP.CLASS:
I didn't use page breaks or BY groups or put each age on a new sheet just so it would make all 3 groups visible in one screen shot.
Here's the code I used:
ods excel file='c:\temp\style_line.xlsx'
options(embedded_titles='yes');
ods escapechar='^';
proc report data=sashelp.class
style(lines)={just=l font_weight=bold vjust=m}
style(column)={protectspecialchars=off};
title 'The title';
where age in (11,12,13);
column age name sex height weight;
define age / order;
define name / order;
define sex / display;
define height / display;
define weight / display;
compute after age;
length tline1 tline2 tline3 $100;
if age = 11 then do;
tline1 = "^{style[color=red]Line 1 in PROC REPORT} (*ESC*){NEWLINE}" ;
lg1 = length(tline1);
tline2 = "^{style[color=purple]Line 2 in PROC REPORT} (*ESC*){NEWLINE}" ;
lg2 = length(tline2);
tline3 = "^{style[color=turquoise]Line 3 in PROC REPORT} (*ESC*){NEWLINE}" ;
lg3 = length(tline3);
end;
else if age = 12 then do;
tline1 = "^{style[color=black]Line 1 in PROC REPORT} (*ESC*){NEWLINE}" ;
lg1 = length(tline1);
tline2 = "^{style[color=black]Have Line 2 but No Line 3}" ;
lg2 = length(tline2);
tline3 = ' ';
lg3 = 0;
end;
else if age = 13 then do;
tline1 = "^{style[color=purple]Line 1 in PROC REPORT} (*ESC*){NEWLINE}" ;
lg1 = length(tline1);
tline2 = " (*ESC*){NEWLINE}";
lg2 = length(tline2);
tline3 = "^{style[color=red]Line 3 (blank for line 2)}" ;
lg3 = length(tline3);
end;
line tline1 $varying. lg1;
line tline2 $varying. lg2;
line tline3 $varying. lg3;
endcomp;
run;
ods excel close;
Hope this helps,
Cynthia
I think in Proc Report Backgroundcolor is more of a CELL property. Which would mean you can't mix background colors.
Separate compute blocks for different line perhaps.
You have also not provided enough code or data to allow us to even test code, making much harder to provide a solution that may work.
@tgleghorn wrote:
the style statement does not work on line statements.
Yes, That's correct. The multiple LINE statements are all writing into one big cell. So you cannot have a different background color for each line. That's why I only changed the foreground color. It is the same in PDF and RTF -- what is in one cell, no matter how many lines has one background color for the whole cell.
Cynthia
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: