Statalist


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

st: AW: RE: join duplicated records from one datafile


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: RE: join duplicated records from one datafile
Date   Tue, 19 Feb 2008 13:45:06 +0100

And subsequently:

forv i=2/5{
rename a`i' var`i'
label var var`i' ""
}

Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945

-----Urspr�ngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Rajesh Tharyan
Gesendet: Dienstag, 19. Februar 2008 13:34
An: [email protected]
Betreff: st: RE: join duplicated records from one datafile

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/


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