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

Hi Guys,

 

here i am using prdsale data set. I am trying to color the quarter column on basis of their number. Ex 1=pink 2=yellow 3=green 4=red.

below is my code but it is not working.

 

proc report data=sashelp.prdsale;
column product quarter;
/*define quarter/ group;*/
COMPUTE quarter;
IF quarter >3
THEN CALL DEFINE(_col_, "style", "STYLE=[BACKGROUND=RED]");
ENDCOMP;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  You can also accomplish what you want to do with a format, no CALL DEFINE needed.

Cynthia

 

proc format;
  value qfmt 1='pink'
             2='yellow'
             3='green'
             4='red';
run;
  
proc report data=sashelp.prdsale;
column product quarter;
define quarter /
       style(column)={background=qfmt.};
run;

View solution in original post

4 REPLIES 4
Ksharp
Super User

By default, numeric variable is ANALYSIS usage, therefore refer to it by xxx.sum .

 

proc report data=sashelp.prdsale nowd;
column product quarter ;
/*define quarter/ group;*/
COMPUTE quarter;
IF quarter.sum >3
THEN CALL DEFINE(_col_, "style", "STYLE=[BACKGROUND=RED]");
ENDCOMP;
run;
Ajayvit
Obsidian | Level 7

Thanks Ksharp

Cynthia_sas
SAS Super FREQ

Hi:

  You can also accomplish what you want to do with a format, no CALL DEFINE needed.

Cynthia

 

proc format;
  value qfmt 1='pink'
             2='yellow'
             3='green'
             4='red';
run;
  
proc report data=sashelp.prdsale;
column product quarter;
define quarter /
       style(column)={background=qfmt.};
run;
Ajayvit
Obsidian | Level 7
Thanks Cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 1491 views
  • 2 likes
  • 3 in conversation