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 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 8 Nov 2006 12:41:29 -0800
Reply-To:   "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject:   Re: what's wrong with my codes? please help!
Comments:   To: Xuhong <zhuxuhong2000@GMAIL.COM>
Content-Type:   text/plain; charset="us-ascii"

Hi,

It is extremely likely that your source dataset contains a variable called "i".

And as soon as you run your original code the row_to_read may be 915, and thus when the SET statement reads the observation from row 915 the value of i gets overwritten and then your DO loop loops around and the test for 100 fails and you only get one observation. If you change your DO loop from "i" to "j" I bet it will work as this sample code below does. e.g.

data file; do i = 1 to 2000; output; end; run;

data work.sample1; do j = 1 to 100; row_to_read = int(uniform(int(time()))*2000+1); put _all_; set work.file point = row_to_read; output; end; stop; run;

Hope this is helpful.

Mark Terjeson Senior Programmer Analyst, IM&R Russell Investment Group

Russell Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Xuhong Sent: Wednesday, November 08, 2006 12:25 PM To: SAS-L@LISTSERV.UGA.EDU Subject: what's wrong with my codes? please help!

Dear all, I have a database with 2000 obeservations and what I need is to random select 100 observations with replacement. But my codes could only generate one observation. Could you help me find out my mistakes in my codes below? Thanks very much!

data work.sample1; do i = 1 to 100; row_to_read = int(uniform(int(time()))*2000+1); set work.file point = row_to_read; output; end; stop; run;


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