Hi,
Below is the proc report i am trying to run,my objective is to color the date cells where modified_date column values is more than 365 days behind the current date.
I am using compute block for this. I am unable to color the cells of Modified_Date column but i have applied a similar compute for File_Size and the color is coming fine.it seems to me a data type issue, can you please guide me.
Also Please note: Modified_Date is numeric.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
proc report data=final1 nowd split='~' headline headskip nowd
style(REPORT)={rules=all bordercolor=black cellspacing=1}
style(header)={borderwidth=0 borderspacing=0 backgroundcolor=cx6495ED color=white font_size=16pt font_face='Franklin Gothic Demi Cond'};
column Owner Group Modified_Date File_Size Filename ;
*column ('Business directory utilisation'('As of - "&SYSDATE."' Owner File_Size Modified_Date Filename)) ;
define Owner / STYLE(HEADER)=[JUST=LEFT];
define File_Size / STYLE(HEADER)=[JUST=LEFT];
define Modified_Date / STYLE(HEADER)=[JUST=LEFT];
define Filename / STYLE(HEADER)=[JUST=LEFT];
compute File_Size;
if substr(File_Size,1,length(File_Size)-1) > 50 then
call define (_col_,"style","style={background=lightgreen}");
if substr(File_Size,1,length(File_Size)-1) > 100 then
call define (_col_,"style","style={background=lightblue}");
if substr(File_Size,1,length(File_Size)-1) > 200 then
call define(_col_,"style","style={background=lightred}");
endcomp;
compute Modified_Date;
if intck('days',Modified_Date1,today()) > 365 then
call define(_col_,"style","style= {background=lightred}");
endcomp;
run;
Sharique,
Modified_date is numeric. Numeric variables have to be referenced by name.statistic inside a compute block, so you would need Modified_date.sum in that statement.
But you probably don't actually want to sum a date, so add DISPLAY to the DEFINE statement and leave the compute block alone.
define Modified_Date / DISPLAY STYLE(HEADER)=[JUST=LEFT];
I also noticed a typo. In the compute block you have Modified_Date1 not Modified_Date.
Well, personal opinion here. I really don't like doing calculations and things in a reporting procedure. Have a datastep which adds a flag into your data (which gets set to non printed in your report), and then use that flag to apply coloring.
Supply some example data in the form of datastep so we could test your code. The example data should have at least one case for each output to test. https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... shows how to generate datastep code from a dataset.
What format is currently assigned to your date variable?
Sharique,
Modified_date is numeric. Numeric variables have to be referenced by name.statistic inside a compute block, so you would need Modified_date.sum in that statement.
But you probably don't actually want to sum a date, so add DISPLAY to the DEFINE statement and leave the compute block alone.
define Modified_Date / DISPLAY STYLE(HEADER)=[JUST=LEFT];
I also noticed a typo. In the compute block you have Modified_Date1 not Modified_Date.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.