Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Use foreach or forvalues to create the long form data


From   "Supnithadnaporn, Anupit" <[email protected]>
To   [email protected]
Subject   st: Use foreach or forvalues to create the long form data
Date   Wed, 15 Oct 2008 23:11:34 -0400 (EDT)

Dear all,

Would you please suggest me how to create data in the long form
by *not* using reshape? I would like to avoid reshape because reshape
takes very very long time. In fact, the final & total number of records 
that I have to create would be around 12,000,000.

I think foreach and forvalues can do this work. 
But, I am a novice in Stata programming and could not figure out so far.

In the beginning, I have only Obsid which is created by

gen Obsid = _n

The desired data would look like this:

Obsid   Vid     Imp
1       1       1
2       1       2
3       1       3
4       1       4
5       2       1
6       2       2
7       2       3
8       2       4

...


100     25      4

Would anybody please help?

Thank you,

Anupit


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



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