Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firstobs option with Proc Sql?

Status
Not open for further replies.

6656

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

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

Michael

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

like :
proc sql inobs = 100;
.....
 
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);
quit;

You get 10 observations back.
 
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;
set ODBCDATABASE.TABLENAME;
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top