Statalist The Stata Listserver


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

st: reshaping problem: unique values in other variables


From   Michael McCulloch <[email protected]>
To   Statalist <[email protected]>
Subject   st: reshaping problem: unique values in other variables
Date   Thu, 16 Mar 2006 21:25:27 -0800

I have data with the following structure:

list id rec med afev wheeze cough date agev
+---------------------------------------------------+
| id dset rec med afev wheeze cough |
|---------------------------------------------------|
| 2 b 1 0 -9 0 0 |
| 2 b 2 1 -9 0 0 |
| 2 a 1 1 1.70 0 0 |
| 2 a 2 0 1.80 0 0 |
| 6 b 1 1 -9 0 1 |
| 6 b 2 1 -9 0 0 |
| 6 a 1 0 2.08 0 1 |
| 6 a 2 0 1.85 0 0 |
+---------------------------------------------------+

I wish to reorganize the data so that there is one row for each ID, with subsets for dset (a or b) and rec (1 or 2) for each of the variables: med, afev, wheeze, cough.

My goal is to have:
id med(a1) med(b1) med(a2) med(b2) afev(a1) afev(b1) afev(a2) afev(b2)
2 1 0 0 1 1.70 -9 1.80 -9
6 0 1 0 1 2.08 -9 1.85 -9

I have tried using the reshape command but each subset does not have unique values of the variables afev, wheeze, and cough.
I have tried using the collapse command, but I do not want to create summary statistics.
I have tried using the contract command, but I do not want to create frequency counts.
Any assistance would be greatly appreciated.





Best wishes,
Michael


____________________________________

Michael McCulloch
Pine Street Clinic
124 Pine Street, San Anselmo, CA 94960-2674
tel 415.407.1357
fax 415.485.1065
email: [email protected]
web: www.pinest.org
www.pinestreetfoundation.org





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