BookmarkSubscribeRSS Feed
Katie
Obsidian | Level 7

Hello,

I am trying to create a report where I would like one row, specifically the row that contains the missing observations, to be highlighted a different color than all the other rows.  I had thought that I had a solution, however I continually get an error message saying that the "Statement is not valid or it is used out of proper order."  Any help you can provide me with would be greatly appreciated.

The code:


TITLE "Birth Weight by Maternal Race / Ethnicity";

PROC REPORT DATA = bw_all2 NOWD STYLE(HEADER)=[BACKGROUND=LIGHTBLUE];

     COLUMN bwcat miss black white hispanic other total;

     DEFINE bwcat / "Birth Weight Category" ORDER CENTER FORMAT=cat.;

     DEFINE miss / "Missing" DISPLAY CENTER;

     DEFINE black / "African American" DISPLAY CENTER;

     DEFINE white / "Caucasian" DISPLAY CENTER;

     DEFINE other / "Other" DISPLAY CENTER;

     DEFINE total / "Total" DISPLAY CENTER:

     COMPUTE bwcat;

          IF bwcat = 1 THEN CALL DEFINE (_ROW_,"style","Style=[BACKGROUND=LIGHTGREY]");

     ENDCOMP;

RUN;

4 REPLIES 4
AncaTilea
Pyrite | Level 9

So, in your code, bwcat = 1 means that bwcat is missing?

When I ran this little piece of code (see below) it worked.

data temp;

set sashelp.class;

if sex = "M" then sex = "";

run;

ods pdf file = "&file_path.\my_file.pdf";

TITLE "No title";

PROC REPORT DATA = temp NOWD STYLE(HEADER)=[BACKGROUND=LIGHTBLUE];

column sex ;

     COMPUTE sex;

          IF sex = "" then call define (_ROW_,"style","Style=[BACKGROUND=red]");

     ENDCOMP;

RUN;

ods pdf close;

So...I wonder what is wrong...?

Anca.

Katie
Obsidian | Level 7

Thank you Anca,

For some reason when I was specifying that I wanted to change a _ROW_ it was not working.  But I deleted that line of code, rewrote it and now it seems to work okay.  I find it very strange.  There must have been a mysterious unknown typo that I could not find.

AncaTilea
Pyrite | Level 9

If you copied that line from some PDF file or what not, sometimes hidden characters are in there that SAS won't know what to do with it.

Smiley Happy

Vince28_Statcan
Quartz | Level 8

Could you post your error log? The following code inspired by yours works for me...

ods pdf file="c:\test.pdf";

proc report data=sashelp.heart(obs=20) NOWD STYLE(HEADER)=[BACKGROUND=LIGHTBLUE];

     column status ageatdeath;

     define status / "test column1" ORDER CENTER;

     define ageatdeath / "test missing formating" DISPLAY CENTER;

     compute ageatdeath;

          if ageatdeath=. then call define(_ROW_, "style", "style=[BACKGROUND=LIGHTGREY]");

     endcomp;

run;

ods pdf close;

P.S. if you copy pasted your code here, I shall mention that the last DEFINE line ends with column instead of semi column...that could be your error.

Vincent

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
  • 4 replies
  • 560 views
  • 6 likes
  • 3 in conversation