Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: join duplicated records from one datafile


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   st: RE: join duplicated records from one datafile
Date   Tue, 19 Feb 2008 12:33:41 -0000

Hi

This might work?

Given this
id  var1

1    3
1    4
1    5
2    2
3    2
4    5

Try,

gen a=var1
reshape wide a, i( id ) j( var1 )

gives

  | id   a2   a3   a4   a5 |
  |------------------------|
  |  1    .    3    4    5 |
  |  2    2    .    .    . |
  |  3    2    .    .    . |
  |  4    .    .    .    5 |

Hope this helps
rajesh


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Bernhard Hansen
Sent: 19 February 2008 12:13
To: [email protected]
Subject: st: join duplicated records from one datafile

Dear statalisters

I have a data file with 2 variables and duplicates on one of these 
like:

id  var1

1    3
1    4
1    5
2    2
3    2
4    5

Now I want to turn each id into one unique record, and turning the
information on var 1 into a range of new variables so that 
I would like to end up with a data file looking like: 

id var1 var2 var 3
1  3     4     5 
2  2     .     .
3  2     .     .
4  5     .     .

Does anyone knows if it is possible?

Regards
B. Hansen

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



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