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 (February 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 Feb 2003 16:58:18 -0500
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: Using a macro to simulate data
Comments: To: Victor Gastanaga <vgastana@UCI.EDU>
Content-Type: text/plain; charset="iso-8859-1"


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; **ID-specific 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. -----Original Message----- From: Victor Gastanaga [mailto:vgastana@UCI.EDU] Sent: Thursday, February 20, 2003 3:33 PM To: SAS-L@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 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;


%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;



proc print data=tmp&id; run;


%mend pmdata;

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