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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 810 views
  • 0 likes
  • 3 in conversation