BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Geo-
Quartz | Level 8

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

4 REPLIES 4
Patrick
Opal | Level 21

@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.

Geo-
Quartz | Level 8
yes I will read them at other leisure time..would you please fix the code ,I need to offer it first..
Kurt_Bremser
Super User

@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.

Astounding
PROC Star

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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