BookmarkSubscribeRSS Feed
tgleghorn
Calcite | Level 5

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;

11 REPLIES 11
ballardw
Super User

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.

Ksharp
Super User
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;

Ksharp_0-1724375164432.png

 

Cynthia_sas
SAS Super FREQ

Hi, Another way to do this conditionally with multiple LINE statements, shown below using just 3 groups from SASHELP.CLASS:

Cynthia_sas_0-1724376729106.png

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

tgleghorn
Calcite | Level 5
How do I put the style with the actual text. tline1 = 'bold measures - triple weighyed'; would it be tline1 = "Bold measures - triple weighyed ^{style[color=purple]Line 1 in PROC REPORT} (*ESC*){NEWLINE}" ;
tgleghorn
Calcite | Level 5
Duh.. I just saw in your code where to put the actual text. my bad.
tgleghorn
Calcite | Level 5
it is ignoring my background colors.

compute after population ;

if population in ('SCO','NHMCR') then do;
text1 = "^{style[background=black color=white] * = STARS Clinical Outcomes Measure} (*ESC*){NEWLINE}" ;
lg1 = length(text1);
text2 = "^{style[background=grey color=black] * CDC Poor Control is an inverse measure - lower is better} (*ESC*){NEWLINE}";
lg2 = length(text2);
text3 = "^{style[background=yellow color=black] Dark yellow indicates current rate is better than MY 2022 final rate.} (*ESC*){NEWLINE}";
lg3 = length(text3);
text4 = "^{style[color=black] Bold measures - triple weighted } (*ESC*){NEWLINE}";
lg4 = length(text4);
text5 = "^{style[color=black] TRC - 2 Star weights - Average of submeasure and Med Rec} (*ESC*){NEWLINE}";
lg5 = length(text5);
end;
else if population in ('MH','NH') then do;
text1 = "^{style[color=black] *-Triple weighted measure(*ESC*){NEWLINE}";
lg1 = length(text1);
text2 = "^{style[color=black] Withhold measure} (*ESC*){NEWLINE}";
lg2 = length(text2);
text3 = "^{style[color=black] } (*ESC*){NEWLINE}";
lg3 = length(text3);
text4 = "^{style[color=black] } (*ESC*){NEWLINE}";
lg3 = length(text4);
text5 = "^{style[color=black] } (*ESC*){NEWLINE}";
lg5 = length(text5);
end;
else do;
text1 = ' ';
lg1 = length(text1);
text2 = ' ';
lg2 = length(text2);
text3 = '';
lg3 = length(text3);
text4 = '';
lg3 = length(text4);
text5 = '';
lg5 = length(text5);
end;
line text1 $varying. lg1;
line text2 $varying. lg2;
line text3 $varying. lg3;
line text4 $varying. lg4;
line text5 $varying. lg5;

endcomp;
tgleghorn
Calcite | Level 5
This is what I am trying to accomplish with the line statements. I have everything working for each sheet except for the formatting of the line statements. The code that was provided as a solution appears to work except for the background color is not working.
tgleghorn
Calcite | Level 5
the style statement does not work on line statements.
ballardw
Super User

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.

 

Cynthia_sas
SAS Super FREQ

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

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 308 views
  • 3 likes
  • 4 in conversation