BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sharique
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
JaneEslinger
SAS Employee

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.  

 

 

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ballardw
Super User

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
Calcite | Level 5
Hi,

to give a general example to work with.
Please find a code below:
could you please help me know how can i highlight date cells where the difference bithween that date value and current date > 365.

>>>>>>>>>>>>>>>>>>>>>>>>>>

data new;
set sashelp.buy;
run;
proc report data=new;
column amount date;
define amount /center;
define date / center;
compute date;
if intck('day',date,date()) > 365 then call define(_col_,"style","style={background=lightred}");
endcomp;
run;
JaneEslinger
SAS Employee

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.  

 

 

Sharique
Calcite | Level 5
Hi Jane,
A you id i tried with display option.
I tried with a sample code as below and i was able to color the date column . I similarly tried in my main code and it worked.
Thanks alot the solution.Really appreciate this.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

data new;
set sashelp.buy;
run;
proc report data=new;
column amount date;
define amount /display;
define date / display;
compute date;
if intck('day',date,date()) > 365 then call define(_col_,"style","style={background=lightred}");
endcomp;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 5 replies
  • 1217 views
  • 0 likes
  • 4 in conversation