Date: Fri, 9 Oct 2009 09:48:43 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: How to repeat a program 10,000 times and How to append the
10,000 datasets
In-Reply-To: <647563.93609.qm@web110207.mail.gq1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1
That could be trivially done with by group processing.
(1) Generate 10 random values 10,000 times, assign each a group number 1 to
10,000
(2) do BY group number
(3) do BY group number
(4) do BY group number
(5) do BY group number
Then you'll have a dataset with mgk and group for 10,000 observations.
If you're not sure how to modify that, paste in the full dataset and us
folks on the list would be glad to help!
-Joe
On Fri, Oct 9, 2009 at 9:36 AM, haiyan chen <haiyan_c@yahoo.com> wrote:
> The original program has at least 5 steps to come to the final dataset as
> the following:
>
> (1) generate 10 random values from a norm(0,1) and order them
> (2) calculate sum and std of the 10 values for later use, named Sn and s
> from now on
> (3) delete the smallest value and then calculate sum of k values of the
> left 9 values where k=1,2,3,4,5,6,7,8,9, named Sk from now on.
> (4) calculate Gk by the formula Gk=(Sk-Sn)/s, where k=1,2,3,4,5,6,7,8,9
> (5) select max(Gk) and output it as a dataset with one variable mgk and one
> observation.
>
> Now I want to repeat the above step to get 10,000 mgk.
>
> Thanks.
> Haiyan
>
> --- On Fri, 10/9/09, Joe Matise <snoopy369@gmail.com> wrote:
>
> From: Joe Matise <snoopy369@gmail.com>
> Subject: Re: How to repeat a program 10,000 times and How to append the
> 10,000 datasets
> To: "haiyan chen" <haiyan_c@yahoo.com>
> Cc: SAS-L@listserv.uga.edu
> Date:
> Friday, October 9, 2009, 10:23 AM
>
> My vote goes for 'rewrite the original program to generate 10,000
> observations' ... obviously depending on the original program, but odds are
> you can do it using BY group processing.
>
> -Joe
>
>
> On Fri, Oct 9, 2009 at 9:17 AM, haiyan chen <haiyan_c@yahoo.com> wrote:
>
> Hello, SAS-L
>
>
>
> I have a SAS program whose final outcome is a dataset with one variable and
> one observation. I then want repeat the program 10,000 times and I want to
> combine the 10,000 datasets into one dataset with one variable and 10,000
> observations.
>
>
>
>
> I know the most inefficient way to do it is to run a macro 10,000 times and
> then use data step with set statement.
>
>
>
> Would someone write an efficient program for me to do it?
>
>
>
> Thanks a lot for your help !
>
>
>
> Haiyan
>
|