Help using Base SAS procedures

ERROR 117-185: There was 1 unclosed DO block.

Reply
Frequent Contributor
Posts: 107

ERROR 117-185: There was 1 unclosed DO block.

Hello All,

 

I have the following code

 

data parmestPG1_;

set parmestPG1;

rename Estimate=Estimate1;

rename Probt=Probt1;

rename stdErr=StdErr1;

 

if Biased^=. then do;

if 0.05<probt1 <= 0.1 then sig1='*';

else if 0.01 <probt1 <=0.05 then sig1='**';

else if probt1 <= 0.01 then sig1='***';

run;

 

I get the following error message:

ERROR 117-185: There was 1 unclosed DO block.

 

Could you please help me fix it?

 

Super User
Posts: 3,927

Re: ERROR 117-185: There was 1 unclosed DO block.

Add an END statement:

 

data parmestPG1_;
set parmestPG1;
rename Estimate=Estimate1;
rename Probt=Probt1;
rename stdErr=StdErr1;
 
if Biased^=. then do;
if 0.05<probt1 <= 0.1 then sig1='*';
else if 0.01 <probt1 <=0.05 then sig1='**';
else if probt1 <= 0.01 then sig1='***';
end;
run;
SAS Super FREQ
Posts: 9,374

Re: ERROR 117-185: There was 1 unclosed DO block.

Hi:
Where is the END; statement for the
if Biased ^=. then do; statement?

Or, did you want a subsetting IF there:
if Biased ^=.; ??

It really depends on your desired results. Do you only want to output the rows where Biased ^= .? Or do you want to output all the rows that are in parmestPG1?
Cynthia;
Super User
Posts: 10,284

Re: ERROR 117-185: There was 1 unclosed DO block.

Visual formatting of code can do wonders for you:

data parmestPG1_;
set parmestPG1;
rename
  Estimate=Estimate1
  Probt=Probt1
  stdErr=StdErr1
;
if Biased ^= .
then do;
  if 0.05 < probt1 <= 0.1
  then sig1 = '*';
  else if 0.01 < probt1 <= 0.05
  then sig1 = '**';
  else if probt1 <= 0.01
  then sig1 = '***';
/* why did I end up one indent in before the run;?
   oh, there's a missing end! */ 
run;

As long as you write spaghetti code, such mistakes won't stand out for you as they do for people who write code in a proper style.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Frequent Contributor
Posts: 107

Re: ERROR 117-185: There was 1 unclosed DO block.

Posted in reply to KurtBremser
So here is a riddle then.

I've changed my code as follows:
1. I've added the end at the end of the code. This in itself DID NOT solve the problem.
2. I've changed the stars to text. This DID solve my problem.

data parmestPG1_;
set parmestPG1;
rename Estimate=Estimate1;
rename Probt=Probt1;
rename stdErr=StdErr1;

if StdErr1^=. then do;
if 0.05<Probt1 <= 0.1 then sig1='1-star';
else if 0.01 <Probt1 <=0.05 then sig1='2-stars';
else if Probt1 <= 0.01 then sig1='3-stars';
*else sig1='';
end;
run;

Super User
Posts: 10,284

Re: ERROR 117-185: There was 1 unclosed DO block.

  1. post example data in a data step
  2. post example data in a data step
  3. post example data in a data step

otherwise you will always get untested code.

I need to add a correction to my previous code:

data parmestPG1_;
set parmestPG1;
rename
  Estimate=Estimate1
  Probt=Probt1
  stdErr=StdErr1
;
length sig1 $3;
if Biased ^= .
then do;
  if 0.05 < probt1 <= 0.1
  then sig1 = '*';
  else if 0.01 < probt1 <= 0.05
  then sig1 = '**';
  else if probt1 <= 0.01
  then sig1 = '***';
end;
run;

Without the length statement, SAS will take the length of the first assigned string for sig1, and you'll only get 1 charascter, no matter how many you assign later.

 

Please post code using the proper buttons ({i} or "little running man"), so that the formatting is preserved.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 5 replies
  • 189 views
  • 0 likes
  • 4 in conversation