BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have the following proc report code:

columns LVL_2 inj_yr, (lost1 avg_emp rate1);
define LVL_2 / group 'Departments;
define inj_yr / across '' ;
define rate1 / analysis 'Rate' width=5;
define avg_emp / analysis 'Avg Emp';
define lost1 / analysis noprint;
compute rate1;
if _c4_>&hi05 then call define ('_c4_',"style","style=[foreground=red]");
attrib='style={flyover="Lost: _c2_"}';
call define('_c4_','style',attrib);
endcomp;

How do I reference the column _c2_? The flyover text works fine, but I'm not sure how to show the actual values for _c2_.
Also, I lose foreground=red when I apply the flyover text. Is it possible to have both the flyover text and foreground=red?
I output to PDF.
Thanks,
Jason
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggestion: it is not necessary to post a particular item in more than one forum.
Tim_SAS
Barite | Level 11
_c2_ is a variable so you reference its value just like any other variable. In this case that means creating the attrib string using the concatenation operator.
[pre]
attrib='style={flyover="Lost: ' || _c2_ || '"}';
[/pre]
Now, regarding getting both style attributes at the same time. What's happening is that each call to the DEFINE routine with a style element replaces any previously defined style elements. The last call always wins.

The solution, like so many solutions in this forum, depends on what version of SAS you're using. If you're using 9.2, PROC REPORT supports the "STYLE/MERGE" attribute.
[pre]
call define(_c4_, "style/merge", attrib);
[/pre]
"STYLE/MERGE" tells the DEFINE routine to merge the style element with the existing style elements. With "STYLE/MERGE", the flyover attribute gets merged with the foreground attribute and so both are used.

If you're using an earlier version of SAS, you have to specify both the flyover attribute and the foreground attribute in the same call to DEFINE.
[pre]
attrib='style={foreground=red flyover="Lost: ' || _c2_ || '"}';
[/pre]
Here's the doc for STYLE/MERGE and its companion STYLE/REPLACE:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473624.htm
deleted_user
Not applicable
I have SAS 9.1/EG 4.1
The correct flyover values now appear, however, I'm not sure how to get foreground=red to be correctly applied:
if _c7_>&hi06 then call define ('_c7_',"style","style=[foreground=red]");
if _c4_>&hi05 then call define ('_c4_',"style","style=[foreground=red]");
attrib='style={flyover="Lost: ' || _c2_ || '"}';
call define('_c4_','style',attrib);
attrib='style={flyover="Lost: ' || _c5_ || '"}';
call define('_c7_','style',attrib);

Thank you.
Cynthia_sas
SAS Super FREQ
Hi:
If you were using SAS 9.2, you could use STYLE/REPLACE or STYLE/MERGE in your CALL DEFINE to apply the red foreground color.

In SAS 9.1.3, I believe your only choice would be to explicitly set the foreground where you set the flyover. It looks like _c4_ and _c7_ will always have some kind of flyover. You could do this (I may not have the logic of what you want to do quite correct -- I was just guessing):

[pre]

if _c7_ > &hi06 then do;
attrib='style={foreground=red flyover="Lost: ' || _c5_ || '"}';
call define ('_c7_',"style",attrib);
end;
else do;
attrib='style={foreground=black flyover="Lost: ' || _c5_ || '"}';
call define ('_c7_',"style",attrib);
end;
[/pre]

cynthia
deleted_user
Not applicable
This works well.
Thank you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 1234 views
  • 0 likes
  • 4 in conversation