BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
jrleighty
Fluorite | Level 6

I'm running the following proc report and having an issue with the compute block.  The only variable created in this step is CholGroup. When I run the code, all observations for CholGroup are <200 despite some readings being above 200 and others being missing. In the log, I receive a note stating 'variable chol is uninitialized'. Any advice on how to fix this would be appreciated.

 

proc report data=cb.blood;
column subject Gender AgeGroup chol CholGroup WBC;
where subject ge 990;
define subject / noprint;
define Gender / group width=8;
define AgeGroup / group width=8;
define Chol / width=8;
define WBC / width=8;
define CholGroup / 'Cholesterol Group' computed;
compute CholGroup / character length=6;
if chol lt 200 then CholGroup = '<200';
if chol gt 200 then CholGroup = '>=200';
endcomp;
define wbc / display;
run;

1 ACCEPTED SOLUTION
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
If your CHOL variable is numeric, then you are referencing the variable incorrectly in your COMPUTE block. Remember that the default usage for a numeric variable is ANALYSIS with a default statistic of SUM. Inside a COMPUTE block when you are using a numeric variable in code, you need to use the compound name:
variable.statistic so that PROC REPORT knows which value to use in the comparison. In this case, I would expect that CHOL.SUM might work instead of just referring to CHOL in your IF statement.
Also, I wonder at your GROUP usage for GENDER and AGEGROUP and whether they might be impacting your values for CHOL and WBC because the default behavior of GROUP would cause your values for CHOL and WBC to be summarized. In addition, you have WBC listed twice, once with a usage of ANALYSIS/SUM and last with a usage of DISPLAY. So it seems like there are some possible issues to clean up in your code. Also, specifying WIDTH=8 is a setting that is ignored for ODS destinations. I'm also curious about the usage for SUBJECT, if it is Character, the default usage would be DISPLAY, but it appears to be NUMERIC, in which case, I'm not sure what purpose SUBJECT is serving on this report.
Are there any WARNINGS or ERRORS in your SAS Log?
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
  • 2 replies
  • 546 views
  • 2 likes
  • 3 in conversation