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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.