I need color coding, as mentioned in the title section
Proc report data = sashelp.class ;
column name age sex weight height ;
run;
See these:
1) https://support.sas.com/resources/papers/proceedings11/290-2011.pdf
2) https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/142-31.pdf
and
3) https://www.lexjansen.com/wuss/2006/tutorials/TUT-Carpenter.pdf
Bart
Hi,
So that people can more easily help you, please share 4 more things:
Thanks & kind regards,
Amir.
Color code what?
"Title" is normally part that goes before a report in SAS so coloring age doesn't make much sense in relation to "title".
To color a value based the value we need to know exactly what to color.
This example colors the background of cell that has the age.
proc format ; value agecolor 11 = 'Yellow' 12, 13 = 'Red' 14, 15 = 'Black' ; run; Proc report data = sashelp.class ; column name age sex weight height ; define name / group; define age / style=[background=agecolor.]; run;
If I run your code I do not get any TITLE printed (unless I had previous run a TITLE statement).
Do you mean you want to change the colors of the column headers in your report?
You can do that with the STYLE option on the DEFINE statement in PROC REPORT.
proc report data = sashelp.class ;
column name age sex weight height ;
define name / style(header)={backgroundcolor=red};
run;
1)
data class;
set sashelp.class;
length x $ 80;
if age in (11:14) then x=cats('(*ESC*){style [foreground=yellow fontsize=2 fontweight=bold]||||||||}age_',age);
else x=cats('(*ESC*){style [foreground=red fontsize=2 fontweight=bold]||||||||}age_',age);
keep name age x;
run;
ods excel file='c:\temp\temp.xlsx';
proc report data=class nowd ;
run;
ods excel close;
2)
data class;
set sashelp.class;
length x $ 80;
y='||||||||'; x=cats('age_',age);
keep name age y x;
run;
ods excel file='c:\temp\temp.xlsx';
proc report data=class nowd ;
column name age y x;
define age/display;
compute y;
if age in (11:14) then call define(_col_,'style','style={background=yellow foreground=yellow}');
else call define(_col_,'style','style={background=red foreground=red}');
endcomp;
run;
ods excel close;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.