LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (October 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 24 Oct 2007 19:19:27 -0400
Reply-To:   "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:   Re: Selecting a Random Sample

On Wed, 24 Oct 2007 00:12:24 -0700, a320@HOTMAIL.COM wrote:

>Hello, > >My data has the following format: >Data A; >ID Year Type >1 1999 A >1 2000 A >1 2001 B >1 2001 C >2 1988 H >3 1989 C >4 2001 G >4 1998 Y >5 2001 B > > > >I want to select a random 20% sample of the IDs. > >So for example, > >The output could be: > >4 2001 G >4 1998 Y > >or the output could be: > >5 2001 B > > >The way I approach it is: >Data B; >set A; >by ID; >retain X; >if first.ID then X = ranuni(4544); >run; > >Data C; >set B; >if X < 0.20 then output; >end; > >This way I would extract 20% of the IDs. My question is: is there a >better/more efficient way to do this? > >Thanks.

Combine the two DATA steps into one.


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