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 (August 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Aug 2008 12:06:21 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Subject:      Re: Deleting extra observations

On Wed, 20 Aug 2008 08:28:58 -0400, Randall Powers <powers_r@BLS.GOV> wrote:

>Hi All, > > I realize this is a SAS 101 question, but I need to ask it anyway. > > I need to keep the first 245,000 observations of my dataset, and delete >the ones beyond that. How do I do this? Note: none of the variables have >convenient values such that and if-then/delete statement will work. > >Thanks!

To delete the observations from the existing data set (rather than creating a new data set containing the subset):

data demo; do rownum = 1 to 245002; output; end; run;

data demo; modify demo; if _n_ > 245000 then remove; run;

It might seem that this could be done more efficiently using the FIRSTOBS= option, but that could cause serious trouble. See http://www.sascommunity.org/wiki/MODIFY_and_FIRSTOBS


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