BookmarkSubscribeRSS Feed
TPayne
Fluorite | Level 6

Hello!

 

I am trying to use a compute statement in my proc report and keep getting the error that the variable error_count is uninitialized, even when included in the proc report. Additionally, my other variables in my compute statements are not changing background in my proc report even if the condition is met. Am I missing something? Thanks so much!

 

 

COLUMN

VFC_PIN REGION FACILITY_NAME FACILITY_TYPE ERROR_COUNT DTAP EXPECTED_DTAP HEPA EXPECTED_HEPA HIB EXPECTED_HIB POLIO EXPECTED_IPV MMR EXPECTED_MMR
PCV EXPECTED_PCV RTV EXPECTED_RTV VARICELLA EXPECTED_VAR ERROR1 ERROR2 ERROR3 ERROR4 ERROR5 ERROR6 ERROR7 ERROR8;

 

DEFINE VFC_PIN  / CENTER "VFC PIN" STYLE(COLUMN)=[BACKGROUND=WHITE] STYLE={TAGATTR='FORMAT:@'};;
DEFINE REGION  / CENTER "REGION" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE FACILITY_NAME / CENTER "FACILITY NAME" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE FACILITY_TYPE / CENTER "FACILITY TYPE" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE ERROR_COUNT / CENTER "# INCORRECT VACCINES" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE DTAP / CENTER "DTP USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_DTAP / CENTER "DTP EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE HEPA / CENTER "HAV USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_HEPA / CENTER "HAV EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE HIB / CENTER "HIB USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_HIB / CENTER "HIB EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE POLIO / CENTER "POLIO USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_IPV / CENTER "POLIO EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE MMR / CENTER "MMR USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_MMR / CENTER "MMR EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE PCV / CENTER "PCV USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_PCV / CENTER "PCV EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE RTV / CENTER "RTV USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_RTV / CENTER "RTV EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE VARICELLA / CENTER "VAR USED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE EXPECTED_VAR / CENTER "VAR EXPECTED" STYLE(COLUMN)=[BACKGROUND=WHITE];
DEFINE ERROR1 / NOPRINT;
DEFINE ERROR2 / NOPRINT;
DEFINE ERROR3 / NOPRINT;
DEFINE ERROR4 / NOPRINT;
DEFINE ERROR5 / NOPRINT;
DEFINE ERROR6 / NOPRINT;
DEFINE ERROR7 / NOPRINT;
DEFINE ERROR8 / NOPRINT;


compute error_count;
if error_count=7 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute dtap;
if error1=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute hepa;
if error2=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute hib;
if error3=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute polio;
if error4=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute mmr;
if error5=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute pcv;
if error6=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute rtv;
if error7=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

compute varicella;
if error8=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;
run;

ODS TAGSETS.EXCELXP CLOSE;

3 REPLIES 3
PaigeMiller
Diamond | Level 26

 

compute error_count;
if error_count=7 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

I don't see a variable named ERROR_COUNT7, so this doesn't work.

 

compute dtap;
if error1=1 then call define(_col_,'style','style={background=LIGHTRED}');
endcomp;

PROC REPORT processes left to right, but you have defined DTAP to the left of (before) ERROR1, so it won't work. You need ERROR1 defined before (to the left of) DTAP. Etc.

 

You either need to re-arrange columns, or use aliases so that the columns appear in the order you want. Example:

 

column vfc_pin region facility_name facility_type error_count 
error1=error1_noprint dtap ...;



...



define error1_noprint/display noprint;

define dtap / display center ...;



...



compute dtap;

if error1_noprint=1 then call define(_col_,'style','style=background=LIGHTRED}');

endcomp;

 

 

 

--
Paige Miller
TPayne
Fluorite | Level 6

Hi Paige! 

 

I do not have a variable error_count7 in my report or my compute statement. could you please explain what you meant?

 

Also, thank you, I did no realize it computes left to right. Rearranging the columns worked!

PaigeMiller
Diamond | Level 26

@TPayne wrote:

I do not have a variable error_count7 in my report or my compute statement. could you please explain what you meant?

 


You do have a variable ERROR_COUNT7 in your code. If you have a variable named ERROR_COUNT7 in your PROC REPORT COLUMNS definition or in a COMPUTE block which doesn't exist, then PROC REPORT doesn't know what to do with the variable ERROR_COUNT7 and returns an error.

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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