Point= and STOP statement confusion?

Reply
Frequent Contributor
Posts: 75

Point= and STOP statement confusion?

Hi, Can anybody explain why the below code does not need a STOP statement and how it manages to detect the end of file?

data a;
set sashelp.class(rename=(name=name1 age=age1 sex=gender height=ht1 weight=wt1));
run;


data w;
set sashelp.class;
do i=1 to nobs by 3;
set a point=i nobs= nobs;
output;
end;
run;

The code works fine, but i am not understanding how does it do without a STOP statement..The  SAS documentation says STOP is a must when we use point= option though. Also, why is my index variable I not written to the output dataset w? I never explicitly dropped it with drop= or drop statement?

Super User
Posts: 7,814

Re: Point= and STOP statement confusion?

This data step executes the do loop completely for every observation in sashelp.class and ends when EOF of sashelp.class is reached.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 298

Re: Point= and STOP statement confusion?

If you have added STOP, you would have got 7 observations. Since there is no STOP it goes on 19 times --- the number of observations in SASHELP.CLASS -- and after finding the EOF in that dataset, Data Step default action stop the iteration. So your output data sets gets 19 times 7 observations (133 observations).

The variable I need no drop because, any variable used to point to POINTER =, will not  go to the Program Data Vector and hence does not appear in the output data set.

Super User
Super User
Posts: 7,060

Re: Point= and STOP statement confusion?

The data step stops when it reads past the end of SASHELP.CLASS in the second statement.

Variables defined by POINT= and NOBS= (and other similar options) are NOT written to the output dataset.

Super User
Posts: 5,513

Re: Point= and STOP statement confusion?

To understand the answer, you have to understand how this DATA step stops:

data w;

set sashelp.class;

run;

You might see more information that would help if you added some diagnostic messages:

data w;

put "Before:  " _all_;

set sashelp.class;

put "After:  " _all_;

run;

Look at how many messages there are, and how many observations were read in.  Once you understand that, we can switch back to your original question.

Good luck.

Ask a Question
Discussion stats
  • 4 replies
  • 373 views
  • 0 likes
  • 5 in conversation