BookmarkSubscribeRSS Feed
gamei0006
Calcite | Level 5

I need highlight each other row and at same time color letter if a>4000, but my code below doesn't work....    can you guys see issue? Thanks!

compute ID;
         count+1;
         if
         a>4999.9999999 and mod(count,2)=1 then
         call define(_row_, "style", "style=[color=red background=white]");
   else if
        a>4999.9999999 and mod(count,2)=0 then
         call define(_row_, "style", "style=[color=red background=lightgrey]");
   else if
         mod(count,2)=1 and a=<4999.9999999  then
            call define(_row_, "style", "style=[background=white]");
         else if
         mod(count,2)=0 and a=<4999.9999999 then
         call define(_row_, "style", "style=[background=lightgrey]");

      endcomp;

2 REPLIES 2
Ksharp
Super User

What is your columns statement ?

Try the following one :

compute A;




Xia Keshan

Cynthia_sas
SAS Super FREQ

HI;

  You really need to post more of your code. for example, if the COLUMN statement is:

COLUMN A ID xxx yyy zzz; Then it should be OK for you to test A in the COMPUTE block for ID. But if the COLUMN statement is:

COLUMN ID A xxx yyy zzz; then  going by the PROC REPORT "left-to-right" rule, at the point in time when PROC REPORT is handling the value for ID, it has not yet placed the value for A on the report row, so the value of A cannot be tested in the compute block for ID.

  Another possibility, which nobody can comment on because you did not include your DEFINE statement for A is whether A is a default usage of DISPLAY or (more likely) since A is numeric a DEFAULT usage of SUM. If A is a default usage of SUM, then you have to test on A.SUM as the compound name (variable_name.statistic - -which is how PROC REPORT wants to reference numeric variables with a usage of ANALYSIS, which is the default usage if you do NOT have a DEFINE statement or you do not list a usage on the DEFINE statement for a numeric variable).

  All of this is outlined well in the PROC REPORT documentation. And, here's an example to get you started http://support.sas.com/resources/papers/proceedings13/366-2013.pdf it uses SASHELP.CLASS, starting around page 12.

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