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   "Jann, Ben" <[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 09:40:08 +0100

Use the -cross- command:

 . clear
 . input str1 var2
 . A
 . B
 . C
 . end
 . tempfile foo
 . save `foo'
 . rename var2 var1
 . cross using "`foo'"
 . sort var1 var2
 . list

ben

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of sarah smith
> Sent: Tuesday, December 21, 2004 7:24 AM
> To: [email protected]
> Subject: st: how to create all possible combinations for the 
> observations of 1-variable data
> 
> 
> Dear Stata users;
> 
> 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.
> Thank you very much,
> Sarah
> *
> *   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/
> 

*
*   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