| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: How to generate id numbers when expanding data
I am not sure that I understand this
egen id = seq(), block(3)
may help.
Nick
[email protected]
Dick Campbell
> For teaching purposes I have created a table of results from
> an imaginary
> experiment as shown below.
>
>
> +----------------------------------+
> | wave cond sex n outcome |
> |----------------------------------|
> 1. | 1 1 1 25 50 |
> 2. | 2 1 1 18 49 |
> 3. | 3 1 1 15 51 |
> 4. | 1 2 1 25 50 |
> 5. | 2 2 1 20 55 |
> |----------------------------------|
> 6. | 3 2 1 19 54 |
> 7. | 1 3 1 25 50 |
> 8. | 2 3 1 16 58 |
> 9. | 3 3 1 14 53 |
> 10. | 1 1 2 25 50 |
> |----------------------------------|
> 11. | 2 1 2 19 51 |
> 12. | 3 1 2 17 50 |
> 13. | 1 2 2 25 50 |
> 14. | 2 2 2 21 57 |
> 15. | 3 2 2 20 56 |
> |----------------------------------|
> 16. | 1 3 2 25 50 |
> 17. | 2 3 2 17 56 |
> 18. | 3 3 2 15 54 |
> +----------------------------------+
>
> The variable labeled "outcome" is a cell mean and I will
> expand the table
> by n cases for each cell.
> I will subsequently manipulate these data by adding random
> error to the
> outcome variable ,
> adding covariates etc.
>
> However, when I eventually analyze the data I need a unique
> id number for
> each case such that each record has an id
> number which stays constant across waves so that I can use
> XT-series routines.
> So, the expanded data set should look like this.
>
>
> +----------------------------------+
> |id wave cond sex outcome |
> |----------------------------------|
> 1. |1 1 1 1 50 |
> 2. |1 2 1 1 49 |
> 3. |1 3 1 1 51 |
> 4. |2 1 1 1 50 |
> 5. |2 2 1 1 55 |
> |----------------------------------|
> 6. |2 3 1 1 54 |
> 7. |3 1 1 1 50 |
> 8. |3 2 1 1 58 |
> 9. |3 3 1 1 53 |
> 10. |4 1 1 1 50 |
> |----------------------------------|
> 11. |4 2 1 1 51 |
> 12. |4 3 1 1 50 |
> 13. |5 1 1 1 50 |
> 14. |5 2 1 1 57 |
> 15. |5 3 1 1 56 |
> |----------------------------------|
> 16. |6 1 1 1 50 |
> 17. |6 2 1 1 56 |
> 18. |6 3 1 1 54 |
>
> etc through the 361 records implied by the data. Within
> each combination of sex and cond there should be n cases
> with an id that stays constant across waves.
>
> I can not seem to figure out how to do this. I would guess that
> -expandcl- should accomplish what I want, but I can't figure out
> how to set it up. Perhaps there is some other clever solution.
> If I were in SAS I would just loop over n with an -output- statement
> and retain the counter as an ID. But I am a bit stymied here.
>
>
> Dick Campbell
> Univ. of Illinois at Chicago
>
>
>
>
> *
> * 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/