<>
This is an attempt to implement what you want. CHeck carefully whether it
does what you want when applied to your real dataset. In particular, the
loop could conceivably run from 1 to any number, I cannot infer it from your
dataset conclusively...
*****
clear*
input ID Time1m1 Time1m2 Time1m3 Time2m1 Time2m2 Time2m3 Time3m1 Time3m2
Time3m3
2018 1 2 1 1 1 1 1 1 2
2020 . . . . . . . . .
2023 . . . . . . . . .
end
compress
list, noobs
reshape long Time1 Time2 Time3, i( ID ) string
drop _j
forv i=1/3{
rename Time`i' m`i'
}
egen float aux = seq(), from(1) to(3) block(1)
egen id=concat(ID aux)
drop ID
drop aux
destring id, gen(ID)
drop id
order ID
l
*****
HTH
Martin
_______________________
----- Original Message -----
From: "Shubhabrata Mukherjee" <[email protected]>
To: "stata forum" <[email protected]>
Sent: Sunday, April 19, 2009 4:06 AM
Subject: st: data management
Hi,
I have a dataset of the form:
Time1 Time2
Time3
m1 m2 m3 m1 m2 m3 m1 m2 m3
ID
2018 1 2 1 1 1 1 1
1 2
2020
............................................................................
2023
..........................................................................
.....................................
and I want my data to look like this:
ID m1 m2 m3
20181 1 2 1
20182 1 1 1
20183 1 1 2
20201 .............................
20202 .....................
20203
20231
20232
20233
........................................
and I was wondering what would be the best way to accomplish this?
Thanks, Joey
*
* 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/
*
* 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/