Statalist


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

st: RE: data reorganization


From   "Steichen, Thomas J." <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: data reorganization
Date   Sat, 7 Feb 2009 18:44:26 -0500

I can't imagine a reason for wanting this but the following code will do so (but in new variables).

levelsof indice, l(i)
qui gen newindice = .
qui gen newyear = ""
local j = 1
foreach index of local i {
  levelsof year if indice == `index', l(yrs) s(", ")
  qui replace newindice = `index' in `j'
  qui replace newyear = "`yrs'" in `j'
  local j = `j' + 1
}

-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Arina Viseth
Sent: Saturday, February 07, 2009 6:08 PM
To: [email protected]
Subject: st: data reorganization

Dear all,

I have a question regarding how to re-organize my data on stata.

Here is how the data currently looks:

Indice Year
1      1990
1      1991
2      2000
2      2001
2      2003
3      1995
3      1996
4      2002

Would it be possible to re-arrange the data so that I would have the following:

Indice  Year
1       1990, 1991
2       2000, 2001, 2003
3       1995, 1996
4       2002


Any suggestion would be very much appreciated. Thank you in advance.

Arina

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

CONFIDENTIALITY  NOTE:  This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.

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