```> ========================================================================= Date: Thu, 20 Feb 2003 13:21:12 -0800 Reply-To: Victor Gastanaga Sender: "SAS(r) Discussion" From: Victor Gastanaga Organization: University of California, Irvine Subject: Re: Using a macro to simulate data To follow up on my original question, I think the problem originates from the following core code. The question is, why does rand('beta',2,3) create the same identical value twice? Perhaps I just don't understand the rand function well. %macro pdata; %do id=1 %to 10; data tmp&id; b23=rand('beta',2,3); put b23=; mu&id=0.97+15.87*b23; **ID-specific mean for PM; run; %end; %mend pdata; %pdata "Victor Gastanaga" wrote in message news:b33du6\$sil\$1@news.service.uci.edu... > 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 subject-specific 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*(1-theta**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); **ID-specific mean for PM; > > do i=1 to 24; > > retain x 0; > > x= mu&id*(1-theta) + theta*x + ( tau*normal(0) ); > > if i>20 then output; > > end; > > run; > > proc print data=tmp&id; run; > > %end; > > %mend pmdata; > > %pmdata > > ```

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