BookmarkSubscribeRSS Feed
bn820
Obsidian | Level 7

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;

1 REPLY 1
ballardw
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1041 views
  • 0 likes
  • 2 in conversation