Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: convert 5 rows to one observation
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
st: RE: convert 5 rows to one observation
Date
Tue, 15 Jun 2010 22:45:08 +0200
<>
Probably (way) too complicated:
***********
clear*
inp str1 myvar
a
b
c
d
e
1
2
3
4
5
s
t
u
v
w
6
7
8
9
10
end
gen byte order=_n
egen int patient = seq(), from(1) to(5) block(1)
bys patient (order): gen byte sub=_n
drop order
reshape wide myvar, i(patient) j(sub)
egen newvar = concat(myvar*)
drop myvar*
list, noo
***********
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Paul O'Brien
Sent: Dienstag, 15. Juni 2010 22:33
To: statalist
Subject: st: convert 5 rows to one observation
hi,
i have data on patients i one variable with 5 rows for each patient and want
to convert to one observation per patient.
a
b
c
d
e
1
2
3
4
5
s
t
u
v
w
6
7
8
9
10
to
a1s6
b2t7
etc
thanks
paul
*
* 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/