BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gamotte
Rhodochrosite | Level 12

Hello,

 

The following program :

 

data empty_class;
    set sashelp.class;
    stop;
run;

data _NULL_;
    put "1";

    eof=0;
    do until (eof);
        set sashelp.class end=eof;
        put name;
    end;

    put "2";

    eof=0;
    do until (eof);
        set empty_class end=eof;
        put name;
    end;

    put "3";
run;

gives the following output in the log :

1
Alfred
Alice
Barbara
Carol
Henry
James
Jane
Janet
Jeffrey
John
Joyce
Judy
Louise
Mary
Philip
Robert
Ronald
Thomas
William
2
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: There were 0 observations read from the data set WORK.EMPTY_CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Why is "3" not displayed and how can it be fixed ?

 

Thanks !

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Trying to read from an empty dataset immediately throws you to the end of the data step, bypassing all remaining statements.

Compare this:

data _null_;
put 'before';
set empty_class;
put 'after';
run;

 

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Trying to read from an empty dataset immediately throws you to the end of the data step, bypassing all remaining statements.

Compare this:

data _null_;
put 'before';
set empty_class;
put 'after';
run;

 

PeterClemmensen
Tourmaline | Level 20

Because the SET statement ends the DATA step because there are no observations to read in your second do until loop

gamotte
Rhodochrosite | Level 12

Thank you @Kurt_Bremser and @PeterClemmensen.

I thought the set on sashelp.class would avoid early termination.

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
  • 3 replies
  • 4952 views
  • 0 likes
  • 3 in conversation