BookmarkSubscribeRSS Feed
anthony28852
Fluorite | Level 6

I have a Proc Report that goes like this

 

Proc Report Data=Table1;

Column A B C;

compute A;

   if B eq 0 then call define(_col_,"style","style={font_weight=bold}");

endcomp;

Run;

 

However, it doesn't work. 

 

The log says that B is uninitialized. Is there a way to solve it? Thanks before.

 

7 REPLIES 7
Ksharp
Super User
proc report is from left to right .

compute A;
---->
compute B;
or
compute C;
anthony28852
Fluorite | Level 6
Sorry, I don't think I get the point. So how do I compute/set variable A based on Variable B? Thanks.
andreas_lds
Jade | Level 19

proc reports reads the variable from left to right, when computing A, B has no value. You have to clone B:

 

Proc Report Data=Table1;
  columns B=_B A B C;

  define _b / noprint;

  compute A;
     if _b eq 0 then call define(_col_,"style","style={font_weight=bold}");
  endcomp;
run;
Ksharp
Super User
compute block is calculated from left to right.
So when you compute it at A , SAS can't know the value of B, because B is after A.
Change :
compute A;
---->
compute B;
or
compute C;

anthony28852
Fluorite | Level 6

I try to do like below (re-arranging the column)

 

Proc Report Data=Table1;

Column B A C;

compute A:

   if B eq 0 then call define(_col_,"style","style={font_weight=bold}");

endcomp;

Run;

 

And still unsuccesful, can you let me know what did I miss out? Thanks.

Ksharp
Super User
You are defining  _COL_ ,so you can only highlight A not B.
Change it as 

compute B:
Cynthia_sas
SAS Super FREQ

Hi: for a concrete example of how PROC REPORT works, review this related posting:

http://communities.sas.com/t5/Base-SAS-Programming/PROC-REPORT-SAS-log-reporting-dataset-variables-a...

 

It has some pseudo-code examples of PROC REPORT's left-to-right processing and how a COMPOUND name has to be used for numeric variables.

 

cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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