The SAS Output Delivery System and reporting techniques

How to customize the background color for a row using Excelxp in a proc rep

Reply
Frequent Contributor
Frequent Contributor
Posts: 81

How to customize the background color for a row using Excelxp in a proc rep

Hi Dear,

Here is my coding. I want to add background colour blue for the row when the value of x = 'b' . My coding seems running without error but I don't see the background color. Can you please let me know how I do it. I am using SAS 9.2 and on Windows XP.

data temp1;
input @1 x $1. @2 y $1. @3 z $1.;
cards;
abc
abd
abf
abc
abw
acw
acq
bcd
;
run;

ODS LISTING CLOSE;
ods tagsets.excelXP path='c:\' file="mytest.XLS" style=newstyle rs= none;

TITLE " my title " ;
ods tagsets.excelXP options(
Sheet_Name="mytes"
Absolute_Column_Width='30,30,10'
);
run;

proc report data=temp1 nowd ;
column x y z;
define x / order ' x';
define y / order 'y';
define z / 'z';


compute after x;
if x='b' then ;
call define (_row_ ,'style','style={background=blue}');
endcomp;
run;

ods _all_ close;
ods LISTING;
Super Contributor
Posts: 394

Re: How to customize the background color for a row using Excelxp in a proc rep

Use

[pre]
compute x;
[/pre]
instead of

[pre]
compute after x;
[/pre]
The latter statement alters the row after the row when the value of x = 'b', and there is no such row.
Frequent Contributor
Frequent Contributor
Posts: 81

Re: How to customize the background color for a row using Excelxp in a proc rep

Hi Tim
When I put compute x, it put color(background blue) for all rows. But my interest in only the row when x='b'. Thanks a lot for your help.


Thanks

Inp
SAS Super FREQ
Posts: 8,868

Re: How to customize the background color for a row using Excelxp in a proc rep

Hi:
I would recommend that you review your IF statement syntax. This code:
[pre]
compute x;
if x='b' then ;
call define (_row_ ,'style','style={background=blue}');
endcomp;
[/pre]

specifically
[pre]
if x='b' then;
[/pre]

is incorrect. It should be either (no semi-colon after 'then'):
[pre]
compute x;
if x='b' then
call define (_row_ ,'style','style={background=blue}');
endcomp;
[/pre]

OR (use do/end construction with the IF)

[pre]
compute x;
if x='b' then do;
call define (_row_ ,'style','style={background=blue}');
end;
endcomp;
[/pre]

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 151 views
  • 0 likes
  • 3 in conversation