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

I'm doing a typical look ahead read when the input data has only one observation I get the WARNING:.  My program still works I just don't want to be warned.

 

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

data next;
   set class end=eof;
   if not eof then set class(firstobs=2 keep=name rename=name=nextname);
   output;
   call missing(nextname);
   run;
proc print;
   run;

 

 

 

34         data next;
35            set class end=eof;
36            if not eof then set class(firstobs=2 keep=name rename=name=nextname);
WARNING: FIRSTOBS option > number of observations in WORK.CLASS.
37            output;
38            call missing(nextname);
39            run;

NOTE: There were 1 observations read from the data set WORK.CLASS.
NOTE: The data set WORK.NEXT has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I don't know of any option to suppress that warning.

You could perhaps use a view to create the look_ahead data.

data class;
   set sashelp.class (obs=1);
run;

data look_ahead / view=look_ahead;
  set class ;
  if _n_ > 1;
  keep=name;
  rename name=nextname;
run;

data next;
   set class end=eof ;
   if not eof then set look_ahead ;
   output;
   call missing(nextname);
run;

Or if it doesn't mess up other things (like FIRST. processing) you could just read the first observation twice and throw away the extra one.

data next;
   set class(obs=1) class end=eof;
   if not eof then set class(keep=name rename=(name=nextname));
   if _n_ > 1 then output;
   call missing(nextname);
run;

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

I don't know of any option to suppress that warning.

You could perhaps use a view to create the look_ahead data.

data class;
   set sashelp.class (obs=1);
run;

data look_ahead / view=look_ahead;
  set class ;
  if _n_ > 1;
  keep=name;
  rename name=nextname;
run;

data next;
   set class end=eof ;
   if not eof then set look_ahead ;
   output;
   call missing(nextname);
run;

Or if it doesn't mess up other things (like FIRST. processing) you could just read the first observation twice and throw away the extra one.

data next;
   set class(obs=1) class end=eof;
   if not eof then set class(keep=name rename=(name=nextname));
   if _n_ > 1 then output;
   call missing(nextname);
run;

 

data_null__
Jade | Level 19

 


@Tom wrote:

I don't know of any option to suppress that warning.

You could perhaps use a view to create the look_ahead data.

data class;
   set sashelp.class (obs=1);
run;

data look_ahead / view=look_ahead;
  set class ;
  if _n_ > 1;
  keep=name;
  rename name=nextname;
run;

data next;
   set class end=eof ;
   if not eof then set look_ahead ;
   output;
   call missing(nextname);
run;

Or if it doesn't mess up other things (like FIRST. processing) you could just read the first observation twice and through away the extra one.

data next;
   set class(obs=1) class end=eof;
   if not eof then set class(keep=name rename=(name=nextname));
   if _n_ > 1 then output;
   call missing(nextname);
run;

 


Thanks Tom, excellent use of view and turning the problem around.  

Ksharp
Super User
John King, 
Can you add one more obs at the end of CLASS ?


data class;
   set sashelp.class (obs=1);
run;

data copy_class;
 set class(keep=name) end=last;
 output;
 if last then do;
  call missing(name);
  output;
 end;
run;

data next;
   set class end=eof;
   if not eof then set copy_class(firstobs=2 keep=name rename=name=nextname);
   output;
   call missing(nextname);
   run;


SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1828 views
  • 3 likes
  • 3 in conversation