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

st: Re: how to create all possible combinations for the observations of 1-variable data


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: how to create all possible combinations for the observations of 1-variable data
Date   Tue, 21 Dec 2004 07:28:23 -0500

* say that the data are in sarah1
gen en = _n
save sarah1,replace
save sarah2,replace
expand 3
rename var1 var2
sort var2
drop en
egen en=seq(), from(1) to(3)
save sarah2,replace
use sarah1
joinby en using sarah2
drop en
l


Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

On Dec 21, 2004, at 2:33 AM, statalist-digest wrote:

I have a 1-variable Stata file like:
var1
A
B
C
and I would like to create all possible combinations of observations as below:
var1 var2
A A
A B
A C
B A
B B
B C
C A
C B
C C
I would appreciate if you can help me how to create above file.
*
*   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