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

Hi,

 

I have  test program and want to control the style of one field based on the value of another field in Proc report.  The program I wrote to test this is below.  The computed block doesn't work as the value of topzip is uninitialized.  But it appears in the check debug file.  ?

 

Thanks!

 

--Ben

 

data pcts;  
input cust pct zip;
topzip+1; 
if lag(cust)^=cust then topzip=1;  
cards;    
1 53 43058
1 17 43220
1 12 43235
1 7  43081
1 4  43214
;;;       
          
proc format;
picture pct low-high= '000% of your clients reside in ';    
run;      
ods escapechar='^'; 
 
options papersize=(1.5in 2.4in);   
 
proc report data=pcts split='\' out=check;
   by cust;
   column square pct zip topzip;
 
   define topzip /noprint;
   define pct    /display format=pct. '^{unicode ''2605''x}' color=red width=10 flow right;
   define zip    /display             'You are located here' color=red left;
   define square /display computed '';

   compute square /character length=20;
      square='^{unicode ''220e''x}';
      if topzip=1 then call define('square','style','style={color=red}');
      if topzip=2 then call define('square','style','style={color=green}');
      if topzip=3 then call define('square','style','style={color=black}');
      if topzip=4 then call define('square','style','style={color=orange}');
      if topzip=5 then call define('square','style','style={color=blue}');
   endcomp;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
   column topzip square pct zip; 
   define topzip / display noprint; 

View solution in original post

4 REPLIES 4
Tim_SAS
Barite | Level 11

PROC REPORT processes columns from left to right. Because square is to the left of topzip, topzip is not defined when the compute block for square is executed. I see that topzip is a non-printing column, so you should be able to just move it to precede square in the COLUMN statement.

 

data_null__
Jade | Level 19
   column topzip square pct zip; 
   define topzip / display noprint; 
BenConner
Pyrite | Level 9

Thanks much!  I had it originally on the left side but had also left out the DISPLAY parameter.  It generated the same 'unitialized' warning when it was not there.

 

This stuff is really slick... 🙂

 

Thanks!

 

-Ben

data_null__
Jade | Level 19

The default for numeric is to summarize so the name of the statistic associated with topzip would be something like topzip.sum (I think).  I don't use PROC REPORT for summary but, I often make the same omission of type.

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!

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
  • 931 views
  • 0 likes
  • 3 in conversation