Help using Base SAS procedures

Reading specified Observations

Reply
Contributor
Posts: 69

Reading specified Observations

I am having a dataset with 100 observations.
I want to read only 5th,19th,21st records using data step and proc sql.
How can I do this?

Regards,
Siddhartha
Respected Advisor
Posts: 4,173

Re: Reading specified Observations

Posted in reply to Siddhartha
data step:
if _n_ in (5,19,21);


SQL:
Using a data step you will first have to add a obsnum variable to your data set, i.e. obsnum=_n_;
Then in the SQL you use: where obsnum in (5,19,21).

Theoretically monotonic() could be used as well but Cynthia made in another tread a very clear point that this is an undocumented function which also has some known issues and as such should not be used at all.
Super Contributor
Super Contributor
Posts: 3,174

Re: Reading specified Observations

With the DATA step approach, review the SAS Language Dictionary DOC for using a SET with the POINT= parameter.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 2 replies
  • 174 views
  • 0 likes
  • 3 in conversation