Date: Wed, 20 Aug 2008 12:06:21 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>"
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>"
Subject: Re: Deleting extra observations
On Wed, 20 Aug 2008 08:28:58 -0400, Randall Powers <powers_r@BLS.GOV> wrote:
> 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.
To delete the observations from the existing data set (rather than creating
a new data set containing the subset):
do rownum = 1 to 245002; output; end;
if _n_ > 245000 then remove;
It might seem that this could be done more efficiently using the FIRSTOBS=
option, but that could cause serious trouble. See