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

st: sorting and referencing


From   "Paley, Irina" <[email protected]>
To   <[email protected]>
Subject   st: sorting and referencing
Date   Wed, 21 Dec 2005 16:24:40 -0500

Dear stata list servers,

Could I ask you for help on a creative solution to the following task, that I seem to find a little unusual (maybe there is an obvious answer to this?)

Suppose each household consists of a male and a female, and I have data on the time they record doing a certain task.

The data looks like this:



			Start task, Male		Finish task, Male		Start task, Female		Finish task, Female	
household 1 		5am				3pm				5pm				10pm
household 2 		7am				2pm				8am				4pm
household 3 		8am				5pm				9pm				4am

I want to sort, within each household, all numbers in ascending order (time increasing as we move to the right), so that the data looks like this:

Start task, Male			
household 1 		5am				3pm				5pm				10pm
household 2 		7am				8am				2pm				4pm
household 3 		8am				5pm				9pm				4am

...And then substitute each time by who it refers to (the male starting or finishing, or the female, so that it looks like this:

Household id		Timing pattern
household 1:		MMFF
household 2:		MFMF
household 3:		MMFF

How would I do that?

Thanks so much for any help you can provide!

Irina





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