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
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
=========================================================================
Date:         Fri, 21 Feb 2003 10:37:33 -0500
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Re: Using a macro to simulate data
Comments: To: WHITLOI1@WESTAT.com
Content-Type: text/plain; charset=US-ASCII

Thanks

I understood about macro and quotation marks in general, but I had the impression that %sysfunc negated that. So you cannot just copy and paste an expression from DATA step code into %sysfunc, and you have to "think macro", at least partly, when coding a %sysfunc argument.

I found a reference to RAND in the "What's New" part of online doc (http://support.sas.com/documentation/onlinedoc/v81/whatsnew/z1499470.htm), so I assumed that details would be provided as well. I should assume less.

>>> Ian Whitlock <WHITLOI1@WESTAT.com> 02/21/03 10:03AM >>> Howard,

RAND can be found in the HELP facility of 8.2, but the documentation is very very sparse. Remember the function is experimental in 8.2. That means you have to experiment to find out how it works and if you want to use it. Perhaps the documentation for version 9 is better.

There are no quotes around BETA in the call

%let theta=%sysfunc(rand(beta,2,3));

because in macro quote marks are literal, i.e. part of the string, as well as have meaning (hide some symbolic meaning). That means when you use "BETA" the value sent to RAND would be a 6 byte string when RAND was only expecting a 4 byte string.

Your suggestion to avoid the proliferation of work data sets is usually very good and particularly wise in this case.

IanWhitlock@westat.com

-----Original Message----- From: Howard_Schreier@ITA.DOC.GOV [mailto:Howard_Schreier@ITA.DOC.GOV]

Sent: Friday, February 21, 2003 7:58 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Using a macro to simulate data

Ian has identified the essential problem.

A few additional thoughts ...

Putting the global parameters in a one-observation dataset works, but a generally more convenient technique is to use macrovariables:

%let theta=%sysfunc(rand(beta,2,3)); %let tau=%sysfunc(sqrt(2.25*(1-&theta**2)));

Maybe Ian will explain why the quotation marks come off the first RAND parameter.

And, by the way, can anybody help me locate the RAND function in the online doc?

Back to Victor's problem: We don't know all of the requirements, but I'm wondering if it's necessary to generate separate datasets for the 10 subjects. I generally prefer to stack data together and add a categorical variable to use in BY-group processing.

In that case, there is no need for a macro; a single DATA step does it:

data tmp(keep=id mu x); do id = 1 to 10; mu=0.97+15.87*rand('beta',3,3); **ID-specific mean for PM; x=0; do i=1 to 24; x= mu*(1-&theta) + &theta*x + ( &tau*normal(0) ); if i>20 then output; end; end; run;


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