 

=========================================================================
 

Date:  Thu, 20 Feb 2003 19:20:39 0800 
ReplyTo:  Victor Gastanaga <vgastana@UCI.EDU> 
Sender:  "SAS(r) Discussion" <SASL@LISTSERV.UGA.EDU> 
From:  Victor Gastanaga <vgastana@UCI.EDU> 
Organization:  University of California, Irvine 
Subject:  Re: Using a macro to simulate data 

Thank you Ian. I'll use the data step option, as opposed to a macro.
"Ian Whitlock" <WHITLOI1@WESTAT.COM> wrote in message
news:9B501B3774931C469BCCCC021BE537223D4427@remailnt2re01.westat.com...
> Victor,
>
> It is the same problem, only this time by design it appears that you
cannot
> get at the seed! Wow! Watchout for anybody who wants you to rund the
code
> again and get the same results.
>
> Here are hints at two possibilities.
>
> %macro pdata;
> %do id=1 %to 10;
> data tmp&id;
> x = sleep ( 2 ) ;
> b23=rand('beta',2,3); put b23=;
> mu&id=0.97+15.87*b23; **IDspecific mean for PM;
> run;
> %end;
> %mend pdata;
> %pdata
>
>
> data w ;
> do i = 1 to 10 ;
> b23=rand('beta',2,3); put b23=;
> output ;
> end ;
> run ;
>
> So, generate all your data in one DATA step and use a WHERE statement to
get
> the right subset.
>
> IanWhitlcok@westat.com
> Original Message
> From: Victor Gastanaga [mailto:vgastana@UCI.EDU]
> Sent: Thursday, February 20, 2003 3:33 PM
> To: SASL@LISTSERV.UGA.EDU
> Subject: Using a macro to simulate data
>
>
> I'm generating artificial data for 10 subjects. For each subject I
generate
> 4 measurements of X, for a total of 40 data points. I randomly determine
the
> mean of X for each subject, and then proceed to generate 4 measurements
> based on each subjectspecific mean.
>
> The 4 values of X are generated following an autoregressive process. My
> problem is this: Every time I run the program I find out that two of the
10
> subjects have identical X data (as revelaed by the proc print below). I
> haven't been able to figure out why. Any guidance will be greatly
> appreciated.
>
> This is my code (where the X variable is called PM):
>
> data one; * first create global parameters;
>
> theta=rand('beta',2,3); **AR(1) coeff for PM;
>
> tau=sqrt(2.25*(1theta**2)); **Std dev for error term in AR(1) for PM;
>
> run;
>
> %macro pmdata;
>
> %do id=1 %to 10;
>
> data tmp&id(keep=mu&id x); set one;
>
> mu&id=0.97+15.87*rand('beta',3,3); **IDspecific mean for PM;
>
> do i=1 to 24;
>
> retain x 0;
>
> x= mu&id*(1theta) + theta*x + ( tau*normal(0) );
>
> if i>20 then output;
>
> end;
>
> run;
>
> proc print data=tmp&id; run;
>
> %end;
>
> %mend pmdata;
