07-26-2013 11:52 AM
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.
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:
IF bwcat = 1 THEN CALL DEFINE (_ROW_,"style","Style=[BACKGROUND=LIGHTGREY]");
07-26-2013 01:16 PM
So, in your code, bwcat = 1 means that bwcat is missing?
When I ran this little piece of code (see below) it worked.
if sex = "M" then sex = "";
ods pdf file = "&file_path.\my_file.pdf";
TITLE "No title";
PROC REPORT DATA = temp NOWD STYLE(HEADER)=[BACKGROUND=LIGHTBLUE];
column sex ;
IF sex = "" then call define (_ROW_,"style","Style=[BACKGROUND=red]");
ods pdf close;
So...I wonder what is wrong...?
07-26-2013 01:21 PM
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.
07-26-2013 01:33 PM
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.
07-26-2013 01:50 PM
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;
if ageatdeath=. then call define(_ROW_, "style", "style=[BACKGROUND=LIGHTGREY]");
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.