Learning SAS? Welcome to the exclusive online community for all SAS learners.

What does end=eod mean?

Occasional Contributor RRM
Occasional Contributor
Posts: 5

What does end=eod mean?

Hello everyone

I have seen a data step that looks something like this:

data new;

     set data old end=eod;

     if eod and _n_=1 then do :




What it is trying to do is output something (line saying "No observations") if there are no observations for a specific ID. However I am having some troubles with it and i am trying to understand more of exactly what it is that it's doing, particularly what the end=eod and the eod and _n_=1 mean.

Any thoughts?

Thank you

Respected Advisor
Posts: 3,777

Re: What does end=eod mean?

Yes but it needs to come before the SET otherwise then there are 0 observations it will never be executed.

You can look at the documentation for the set statement for explanation of SET statement option END.

Super User
Super User
Posts: 7,433

Re: What does end=eod mean?

If you want to check observations counts, then you could query the sashelp table:

proc sql;

     create table HAVE (avar char(20),anum num);


data _null_;

     set sashelp.vtable (where=(libname="WORK" and memname="HAVE" and nobs=0));  /* I.e. only get records if the dataset has zero observations */

     call execute('data have; avar="No observations"; run;');

/* The above line will only be run if there is a record returned for zero observations, then the extra datastep will be generated */


Alternatively you could do:

data _null_;

     set sashelp.vtable (where=(libname="WORK" and memname="HAVE" and nobs=0));

     call symputx('NOBS',put(nobs,best.);


and then use &NOBS. in a macro.

Respected Advisor
Posts: 3,777

Re: What does end=eod mean?

For a simple "NO DATA" check, finding the actual number of observations is not necessary.

data class;
set sashelp.class;
data _null_;
if _n_ eq 1 and eof then do;
put 'NOTE: No data';
set class(drop=_all_) end=eof;

23         data class;
24            stop;
25            set sashelp.class;
26            run;

The data set WORK.CLASS has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time          
0.02 seconds
      cpu time           
0.00 seconds

27         data _null_;
28            if _n_ eq 1 and eof then do;
29               put 'NOTE: No data';
30               end;
31            stop;
32            set class(drop=_all_) end=eof;
33            run;

No data
NOTE: There were
0 observations read from the data set WORK.CLASS.
Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation