BookmarkSubscribeRSS Feed
Inp
Obsidian | Level 7 Inp
Obsidian | Level 7
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;
3 REPLIES 3
Tim_SAS
Barite | Level 11
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.
Inp
Obsidian | Level 7 Inp
Obsidian | Level 7
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
Cynthia_sas
Diamond | Level 26
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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1361 views
  • 0 likes
  • 3 in conversation