Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Firstobs option with Proc Sql?

Firstobs option with Proc Sql?

Firstobs option with Proc Sql?

Hi, Does anyone know that there are the same function (firstobs=5 obs=100)in data option for proc sql?  


RE: Firstobs option with Proc Sql?

Seeems like firstobs will denote the obs in the dataset and obs will denote the number in the result set.


RE: Firstobs option with Proc Sql?

inobs =  option will limit number of observations retrieved from passthrough sql;

like :
proc sql inobs = 100;

RE: Firstobs option with Proc Sql?

Alright, PROC SQL has inobs and outobs options. There is not equivalent option as firstobs. But you can still use firstobs and obs option in PROC SQL:

proc sql;
create table TWO as
select *
from ONE(firstobs = 11 obs = 20);

You get 10 observations back.

RE: Firstobs option with Proc Sql?

or you can always go back to 'old school' SAS (before Proc SQL) just use _N_ to figure out which record you are on and output accordingly.  (for those of you that do not know - _N_ is the observation variable that you do not see - unless looking for it)

so :
data one;
If _N_ >= 5 & _N_ <= 105 Then Output;

(in one client job I have also been known to sort the data and then get just the even numbered records in a range for a sample)

I still say that Proc SQL was put there for SQL DBAs like me --- but you can do MANY things with SAS data steps that you can not easily in SQL.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close