BookmarkSubscribeRSS Feed
GKati
Pyrite | Level 9

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?

 

5 REPLIES 5
SASKiwi
PROC Star

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;
Cynthia_sas
SAS Super FREQ
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;
Kurt_Bremser
Super User

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.

GKati
Pyrite | Level 9
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;

Kurt_Bremser
Super User
  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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 3195 views
  • 0 likes
  • 4 in conversation