LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 24 Nov 2006 04:33:53 -0800
Reply-To:   Joep <jsteeman@BUSINESSDECISION.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Joep <jsteeman@BUSINESSDECISION.COM>
Organization:   http://groups.google.com
Subject:   Re: A question about how to get the last observation in a data set
Comments:   To: sas-l@uga.edu
Content-Type:   text/plain; charset="gb2312"

Minze,

If you do not want to read the entire dataset you can use point=

data pipo; do i = 1 to 100; output; end; run;

data pipo2; set pipo point=n_records nobs=n_records; put _all_; output; stop; run;

In the log: n_records=100 i=100 _ERROR_=0 _N_=1 NOTE: The data set WORK.PIPO2 has 1 observations and 1 variables. NOTE: DATA statement used: real time 0.00 seconds cpu time 0.00 seconds

Do not forget the output and the stop statement.

Hope this is helpful,

Joep

zhichao.luo schreef:

> You can use this way, then you can selcet what ever obs you want. > I also curious about how to use _n_ to select obs, but I don't find > the method. So I find a more complex way to slect obs I need.8-) > > /*This step to make a variate which is the same as obs*/ > data temp; > set temp(in=a); > if a; > n+1;/*n is obs*/ > run; > > /* you can change the value of n to select whatever obs you like*/ > proc sql; > select * from temp where n= (select count(*) from temp); > > > > "Minze Su дµÀ£º > " > > hi all: > > > > I want to know how to get the last observation by using the data step. > > > > Maybe _n_ £½ last I think £¿ but does anyone know£¿ > > > > Thanks > > > > BR£¬ > > > > Minze


Back to: Top of message | Previous page | Main SAS-L page