DATA Step, Macro, Functions and more

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

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

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

data _null_;

if month(today())=1 then

        do;

            proc sql noprint;

               insert into table1(date,tag)

               set date=today(),

                tag=0;

       end;

else;

      do;

            %put @@@@@NO NEED TO INSERT@@@@@@;

      end;

run;

 

There was 1 unclosed DO block,but I can't find it..how to fix?thanks!


Accepted Solutions
Solution
‎03-21-2018 06:35 AM
Super User
Posts: 6,543

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

To build upon what you already have:

 

 

data _null_;

if month(today())=1 then call execute(

            'proc sql noprint;

               insert into table1(date,tag)

               set date=today(),

                tag=0;');

else put '@@@@@NO NEED TO INSERT@@@@@@';

run;

 

This not only fixes the unclosed DO block, but corrects a significant number of other errors you would have encountered after the DO block was fixed.  I can't promise that your SQL syntax is correct, but you will soon find that out.  I just have to assume that it's correct.

View solution in original post


All Replies
Respected Advisor
Posts: 4,566

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

@Geo-

1. You can't mix a SAS data step with a Proc SQL.

2. A macro %put statement used in a SAS data step Do Loop won't work as you believe.

 

Also based on your other post: You need to read-up a bit how SAS Macro processing works and how it relates to SAS data and Proc steps as it clearly shows that you haven't grasped the concept yet.

Contributor
Posts: 36

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

yes I will read them at other leisure time..would you please fix the code ,I need to offer it first..
Super User
Posts: 9,611

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


@Geo- wrote:
yes I will read them at other leisure time..would you please fix the code ,I need to offer it first..

From my Maxim 13:

Never say "I don't have the time to learn that now". The time to learn is NOW.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎03-21-2018 06:35 AM
Super User
Posts: 6,543

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

To build upon what you already have:

 

 

data _null_;

if month(today())=1 then call execute(

            'proc sql noprint;

               insert into table1(date,tag)

               set date=today(),

                tag=0;');

else put '@@@@@NO NEED TO INSERT@@@@@@';

run;

 

This not only fixes the unclosed DO block, but corrects a significant number of other errors you would have encountered after the DO block was fixed.  I can't promise that your SQL syntax is correct, but you will soon find that out.  I just have to assume that it's correct.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 137 views
  • 0 likes
  • 4 in conversation