I am working on an excel report that is automatically generated by SAS and i need to have some of the columns formatted.
The dataframe has a format like this:
category | subcategory | January | February | March |
---|---|---|---|---|
Name | subname | 0 | 150 | 347 |
And i want the numbers in the month columns to have a red font only in case the number is not zero.
I am using the following code:
PROC FORMAT;
VALUE NOK
0 = 'BLACK'
OTHER = 'RED';
RUN;
ODS EXCEL
file="/route/here/file.xlsx"
OPTIONS(SHEET_NAME="Report" SHEET_INTERVAL='NONE');
PROC REPORT DATA=MONTHS style(column)={foreground=nok.};
RUN;
However when i use this code the words name and subname are also in red. I would like to exclude those columns from the reporting format and i haven't figured out how to do that yet.
How can i either exclude those columns or modify my formatting code so only the months columns are formatted.
Thanks.
Only apply it on the columns which need it.
data wide;
length category subcategory $20;
input category subcategory January February March;
cards;
Name subname 0 150 347
;
proc report data=wide;
define January--March /style(column)={foreground=nok.} ;
run;
Or if it is easier set the other columns to black.
proc report data=wide style(column)={foreground=nok.};
define category /style(column)={foreground=black} ;
define subcategory /style(column)={foreground=black} ;
run;