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:45:50 -0800
Reply-To: cassell.david@EPAMAIL.EPA.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "David L. Cassell" <cassell.david@EPAMAIL.EPA.GOV>
Subject: Re: Using a macro to simulate data
Content-type: text/plain; charset=us-ascii
Ian Whitlock <WHITLOI1@WESTAT.COM>, in one of his replies, wrote in
part:
> I suggest that you use
>
> %let seed = %sysevalf(%sysfunc(time()) + 1001 * &id) ;
While I would never disagree with Ian, I much prefer his guidance in
another post in the same thread. I strongly recommend using a fixed
seed at the beginning of your simulation, and then transferring the
sequences form the pseudo-random number generator into later parts
of one's (macro) code, so that all the code runs from a single seed.
Being able to replicate one's analysis is crucial. Particularly since
the Big Boss will only think to ask you to repeat your work exactly in
the case where you can't replicate your work. :-) Seriously, you need
to be able to do this replication so that others can validate your
research.
Ian's above code is a fine way to generate a random seed for you to use
as a starting value. I often use the following snippet of Perl code to
get some random starts for some SAS programs we run here:
#!/usr/local/bin/perl
# gr3.pl - *G*enerate *R*andoms for SAS design programs
# last mod: David L. Cassell, 2001/09/20
# Usage: gr3.pl [n]
# [where n is an optional number of random numbers, between 0 and
2**31-1,
# to be printed in %010d format, with the default set at 10 random
numbers]
# Note 1: 2**31 is used in the rand() call because SAS uses the range 0
to 2**31-1
# Note 2: a call to srand() is no longer needed, as of Perl 5.004
map { printf "%010d\n", int rand 2**31 } ( 1..(shift||10) )
Umm, yes, that is *one* line of code, with 7 lines of documentation.
David
--
David Cassell, CSC
Cassell.David@epa.gov
|