Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: long table

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: long table Date Wed, 15 Jun 2011 08:28:36 +0100

```Also check out -egen-'s -seq()- function.

. set obs 6
obs was 0, now 6

. egen a = seq() , from(1) block(3)

. egen b = seq() , from(-3) to(-5)

. l

+--------+
| a    b |
|--------|
1. | 1   -3 |
2. | 1   -4 |
3. | 1   -5 |
4. | 2   -3 |
5. | 2   -4 |
|--------|
6. | 2   -5 |
+--------+

On Wed, Jun 15, 2011 at 8:10 AM, Maarten Buis <maartenlbuis@gmail.com> wrote:
> An alternative is to use the -cross- command, see -help cross- and
> Charles H. Franklin (2006) "Stata tip 29: For all times and all
> places", The Stata Journal, 6(1): 147-148.
> http://www.stata-journal.com/article.html?article=dm0020
>
> Hope this helps,
> Maarten
>
> --- On Wed, Jun 15, 2011 at 3:47 AM, Argyn Kuketayev wrote:
>> you need a cartesian product. i don;t know if this is the best
>> approach, but i would create a new constant variable in both files:
>>
>> gen c=1
>>
>> then perform
>> merge m:m c
>>
>>
> --- On Tue, Jun 14, 2011 at 8:06 PM,  <ningli_yang@fastmail.fm> wrote:
>>> I use Stata/MP 11 for Windows.
>>>
>>> Suppose dataset A contains variable a of two elements 1 and 2.
>>> Dataset B contains variable b of three elements -3, -4 and -5.
>>>
>>> What is the Stata command to create the dataset that contains the
>>> following two columns
>>>
>>> 1  -3
>>> 1  -4
>>> 1  -5
>>> 2  -3
>>> 2  -4
>>> 2  -5

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```