Date: Thu, 5 May 2005 15:11:47 -0700
Reply-To: Dale McLerran <stringplayer_2@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <stringplayer_2@YAHOO.COM>
Subject: Re: Efficient Way to write out all possibilities
In-Reply-To: 6667
Content-Type: text/plain; charset=us-ascii
--- Iris Hui <iris_hui@BERKELEY.EDU> wrote:
> I have 5 variables:
> age (73 categories that go from age 0 to age 72);
> education (5 categories, less than high school, hs grad, some
> college,BA,
> grad school);
> sex (2 categories, male, female);
> cohort (3 categories, cohort 1,2,3);
> trial (2 categories, trial 1, 2);
>
> I need to create a dataset that contains all the possible combination
> of
> these 5 variables. I know the dataset should have 73*5*2*3*2=4380
> lines.
> What's an efficient way to program SAS to develop that data?
>
> Any help would be highly appreciated!
>
> Iris
>
Iris,
You have already received several replies which provide explicit
code that can be used to construct a data set. My guess is that
you want a code driven approach using nested do loops (to use
terminology from Howard Schreier's post). Others have shown how
to implement nested do loops. There is no need for me to add such
code here.
But let me point out that you have not told us the purpose that
is to be served by constructing this data set. Right off hand,
I don't know of any good reason why one would want to construct
the table which you indicate unless you wanted a data driven
table. At the same time, I do interpret your post as a request
for code which would construct the code driven table. Perhaps
you would like to state the bigger picture. It is quite possible
that, given the big picture, you do not really need to write out
the table obtained from nested do loops. We (SAS-L, not me) might
be able to provide much better help if we know just what the
problem is that you are trying to solve.
Dale
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@NO_SPAMfhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail
|