Thank you very much Nick, Jann and Kit;
Nick, fillin command is really very handy!
Best,
Sarah
On Tue, 21 Dec 2004 12:08:16 +0000, n j cox <[email protected]> wrote:
> Alternatively, use -fillin-.
>
> . gen var2 = var1
> . fillin var1 var2
>
> -fillin- is clearly one of the most overlooked
> commands. A search of the Statalist archives
> reveals lots of questions to which -fillin-
> is the answer.
>
> In an attempt to flag its prime importance,
> we will carry a tip 17 in Stata Journal 5(1) 2005
> on "Filling in the gaps".
>
> In nearby terrain, check out also -egen, fill()-,
> -egen, seq()- (both official Stata) and
> -egen, repeat()- (-egenmore- from SSC). The last
> can reproduce strings.
>
> Nick
> [email protected]
>
> Ben Jann replied to Sarah Smith:
>
> 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
>
> > 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/
>
*
* 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/