BookmarkSubscribeRSS Feed
omega1983
Calcite | Level 5

data decision3;

  set decision2a;

  by ln_no;

***Streamline***;

    if template_NM IN ('STR1','STR2') then do;

     if DEN_REASON_CD in ('DI','II','PM','NH','TI','NV','BR','IN','ID','IM','ER') then denial_count = 0.50;

    if trial_count = 1 then do; trial = 0.50; approval = 0.50; total = 0.50; final = 0.50; denial = 0.50; end;

     if final_count > 0 then do; final = 0.50; approval = 0.50; total = 0.50; trial = 0; denial = 0.50; end;

     if denial_count = 1 then do; denial = 0.50; approval = 0.50; total = 0.50; trial = 0.50; final = 0.50; end;

  end;

  else do;

  

***Not Streamline***;

  if template not IN ('STR1','STR2') then do;

  if  LM_REFERRAL_CD in ('TD3','4BN') then do;

    if DEN_REASON_CD in ('DI','II','PM','NH','TI','NV','BR','IN','ID','IM','ER') then denial_count = 1;

    if trial_count = 1 then do; trial = 0.25; approval = 0.25; total = 0.25; final = 0; denial = 0; end;

     if final_count > 0 then do; final = 0.25; approval = 0.25; total = 0.25; trial = 0; denial = 0; end;

     if denial_count = 1 then do; denial = 0.25; approval = 0; total = 0.25; trial = 0; final = 0; end;

  end;

  else do;

    if trial_count = 1 then do; trial = 1; approval = 1; total = 1; final = 0; denial = 0; end;

    if final_count > 0 then do; final = final_count; approval = final; total = final_count; trial = 0; denial = 0; end;

    if denial_count = 1 then do; denial = 1; approval = 0; total = 1; trial = 0; final = 0; end;

  end;

  if approval > 0 then LM_DEN_REASON_CD = ' ';

  PROC_STRING = strip(put(LM_REFERRAL_CD,$amname.)) || " - " || strip(LM_REFERRAL_CD);

  drop trial_count final_count denial_count; end;

run;

proc sort data=decision3;

  by LM_REFERRAL_CD ln_no;

run;

By chance do you see anything wrong with the code.  I keep getting error below. It appears I have my do; and end; accounted for but it shows the error after run; twice yet in my code I show run; once.

485       

486          drop trial_count final_count denial_count;end;

487       

488        run;

488        run;

              _

              117

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

It looks like the problem occurs toward the end of the program.  The code only shows run; once but shows it twice in the error message

5 REPLIES 5
Tom
Super User Tom
Super User

If you fix the indentation it will be obvious, see updated code below.

It looks like these two DO statements are missing END statements.

else do;

  ***Not Streamline***;

  if template not IN ('STR1','STR2') then do;


Actually just one of them are missing ENDs as there is an END; statement on the end of the line with the DROP statement.

data decision3;

  set decision2a;

  by ln_no;

  if template_NM IN ('STR1','STR2') then do;

    ***Streamline***;

    if DEN_REASON_CD in ('DI','II','PM','NH','TI','NV','BR','IN','ID','IM','ER') then denial_count = 0.50;

    if trial_count = 1 then do;

      trial = 0.50; approval = 0.50; total = 0.50; final = 0.50; denial = 0.50;

    end;

    if final_count > 0 then do;

      final = 0.50; approval = 0.50; total = 0.50; trial = 0; denial = 0.50;

    end;

    if denial_count = 1 then do;

      denial = 0.50; approval = 0.50; total = 0.50; trial = 0.50; final = 0.50;

    end;

  end;

  else do;

    ***Not Streamline***;

    if template not IN ('STR1','STR2') then do;

      if  LM_REFERRAL_CD in ('TD3','4BN') then do;

        if DEN_REASON_CD in ('DI','II','PM','NH','TI','NV','BR','IN','ID','IM','ER') then denial_count = 1;

        if trial_count = 1 then do;

          trial = 0.25; approval = 0.25; total = 0.25; final = 0; denial = 0;

        end;

        if final_count > 0 then do;

          final = 0.25; approval = 0.25; total = 0.25; trial = 0; denial = 0;

        end;

        if denial_count = 1 then do;

          denial = 0.25; approval = 0; total = 0.25; trial = 0; final = 0;

        end;

      end;

      else do;

        if trial_count = 1 then do;

          trial = 1; approval = 1; total = 1; final = 0; denial = 0;

        end;

        if final_count > 0 then do;

          final = final_count; approval = final; total = final_count; trial = 0; denial = 0;

        end;

        if denial_count = 1 then do;

          denial = 1; approval = 0; total = 1; trial = 0; final = 0;

        end;

      end;

      if approval > 0 then LM_DEN_REASON_CD = ' ';

      PROC_STRING = strip(put(LM_REFERRAL_CD,$amname.)) || " - " || strip(LM_REFERRAL_CD);

    end;

  end;

  drop trial_count final_count denial_count;

run;

omega1983
Calcite | Level 5

Thanks

Peter_C
Rhodochrosite | Level 12

a useful keyboard combination will help you with this DO-block problem:

within the do-block, press alt+(

in fact any bracket-type key ( ( ) { } [] ) would do

repeated presses move the cursor between beginning and end of the block

omega1983
Calcite | Level 5

O wow. I knew you could do that with () but I did not know you accomplish the same thing with your do end statments. Thanks I will try it

Doc_Duke
Rhodochrosite | Level 12

Tom found your missing end; statement (though not analyzing the logic as to where to put it).

An easy way to see this is if you have access to EGuide 5.1.  Paste the code into a program task, it <ctrl>+I and it will reformat the code.  At that point the missing end; is obvious.

The "run;" statement appearing twice is just an artifact of how SAS reports errors.  Note that the same line number is on each "run;" so it is the same statement.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 9268 views
  • 2 likes
  • 4 in conversation