I am trying to alternate color the rows in my report but I keep getting and error :
ERROR 180-322: Statement is not valid or it is used out of proper order.
ERROR 161-185: No matching DO/SELECT statement.
Code below:
column ('Brooklyn - Homevisitng and BF Observation Success' (babydate_character dispname('Homevisiting Success' count_Yes pct_row_Yes count_No pct_row_No Total_S))
('BF Observations' count_0 pct_row_0 count_1 pct_row_1 count_2 pct_row_2 Total_obs));
define babydate_character/display "Baby's DOB" style=[CELLWIDTH=120] noprint;
define count_Yes/display sum 'Yes' style=[CELLWIDTH=60];
define pct_row_Yes/display 'Percent Yes' style=[CELLWIDTH=115];
define count_No/display sum 'No' style=[CELLWIDTH=60];
define pct_row_No/display 'Percent No' style=[CELLWIDTH=110];
define Total_S/display sum 'Total' style=[CELLWIDTH=60];
define count_0/display sum 'No Obs' style=[CELLWIDTH=80];
define pct_row_0/display '% No Obs' style=[CELLWIDTH=100];
define count_1/display sum '1 Obs' style=[CELLWIDTH=70];
define pct_row_1/DISPLAY '% 1 Obs' style=[CELLWIDTH=100];
define count_2/DISPLAY sum '2+ Obs' style=[CELLWIDTH=80];
define pct_row_2/DISPLAY '% 2+ Obs' style=[CELLWIDTH=100];
define Total_obs/display sum 'Total' style=[CELLWIDTH=60];
define dispname/computed "Baby's DOB" style=[CELLWIDTH=120];
RBREAK AFTER / SUMMARIZE ;
compute dispname/ character length=13;
dispname=babydate_character;
endcomp;
COMPUTE AFTER;
dispname = 'Total';
compute babydate_character ;
count + 1 ;
if mod( count, 2 ) then
call define( _row_, 'style', 'style=[background = cxd9d9d9]' ) ;
else call define( _row_, 'style', 'style=[background = cxe9f3ff]' ) ;
end;
ENDCOMP;
RUN;
Please do not separate error messages for the log of the code. Typically SAS provides diagnostic characters placed in the code for some of these messages and it is much easier to diagnosis with the entire log of the procedure. Copy all of the text for a procedure with all of the notes, not just errors. Then on the forum open a text box using the </> icon that appears above the main message box and paste all the text.
Likely the No matching DO is coming from here:
compute babydate_character ; count + 1 ; if mod( count, 2 ) then call define( _row_, 'style', 'style=[background = cxd9d9d9]' ) ; else call define( _row_, 'style', 'style=[background = cxe9f3ff]' ) ; end; ENDCOMP;
There is nothing indicating a DO or Select prior to that end in the compute block.
Likely the cause of the "Statement is not valid" as well.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: