Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Another resphaping problem


From   Sascha Robert <sascha.robert@iew.unizh.ch>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Another resphaping problem
Date   Sat, 16 Apr 2005 10:48:44 +0200

Hi Svend,

It works just fine!

When it comes to problem solving in STATA, I seem to lack the necessary foresight. Hopefully with time I will improve my respective abilities...

Thankyou very much,
Sascha

Svend Juul wrote:

Sascha,
No, it is not ridiculous - but it is solvable.
Each pair of observations must have an unique id, and if your data are as regular as claimed, you can create the id by:
generate id=int((_n+1.1)/2)

Adding 1.1 instead of 1 makes sure that rounding
errors don't mess things up. It goes like this:
clear
input group var strategy
1 11 0
1 12 1
1 13 0
1 14 1
2 15 0
2 16 1
end
generate id=int((_n+1.1)/2)
reshape wide var , i(id group) j(strategy)
list

Isn't that what you wanted?
Svend
________________________________________________________ Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 DK-8000 Aarhus C, Denmark Phone, work: +45 8942 6090 Phone, home: +45 8693 7796 Fax: +45 8613 1580 E-mail: sj@soci.au.dk _________________________________________________________
*
* 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/


--
***** sascha robert | mailto: sascha.robert@iew.unizh.ch *****
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index