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?
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;
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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.