Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: all possible combinations of three numlists


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: all possible combinations of three numlists
Date   Thu, 14 Oct 2004 13:07:53 -0400

It may be easiest if you just specify the values missing from 1-99 after
creating a complete list:

set obs 99
gen i=_n
expand 99
bysort i: gen j=_n
expand 17
bys i j: gen k=_n

gives you all combinations of i and j running 1 to 99 and k 1 to 17.  You
could then get rid of all of the combinations you don't want by:

drop if inlist(i,3,5,6,......)
drop if inlist(j,3,5,6......)

inserting the list of values you don't want in the inlist function.

Michael Blasnik
[email protected]

----- Original Message ----- 
From: "Alexand Shepotilo" <[email protected]>
To: <[email protected]>
Sent: Thursday, October 14, 2004 12:52 PM
Subject: st: all possible combinations of three numlists


> Hi statalist users,
>
> I have 3 numlists i=1-99 j=1-99 and k=1-17. i and j are actually the
> same but numbers go 1,2,4,7...99 (total of 79 elements). k goes exactly
> from 1 to 17.
> I want to construct dataset of three variables i, j, and k that will
> have all possible combinations ie
> i   j   k
> 1  1   1
> 1  1   2
> ........
>
> 99 99 17
>
> Are there any tools to do this?


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index