Date: Fri, 18 Dec 1998 08:19:00 +1000
Reply-To: "Jindal, Shekhar [IBM GSA]" <SJindal@NITGNPSD.TELSTRA.COM.AU>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Jindal, Shekhar [IBM GSA]" <SJindal@NITGNPSD.TELSTRA.COM.AU>
Subject: Re: Sort variables within an observation
1. You need to TRANSPOSE the dataset (to get the new var - DRUG and
2. Sort by RESPONDER and AGE.
3. Get rid of OBS with missing AGE.
4. (UN)TRANSPOSE it by DRUG (to give you 5 vars - DRUG1-DRUG5) - I assume
that you are not interested in the _exact_ AGE at which they tried their
DRUGs (If you are, then use AGE as well in this step).
5. You have your data.
The code should be easy enough (I guess).
>From: Peter Flom
>Subject: Sort variables within an observation
>Date: Friday, 18 December 1998 8:10
>I have a data set with several hundred observations. Each observation
>contains (among a lot of other stuff) 5 variable corresponding to the age
>which the subject first did something. Each of these could be missing, or
>range from 1 to 25.
>The "somethings" are various drugs: Marijuana, cocaine, etc.
>What I would like is, for each person, to get a data set containing which
>drug the person did first, second, third, fourth, or fifth. There are a
>couple complications. Each person could have done any, some, or all of the
>drugs. They could do them in any order. And they could have started doing
>two (or more) at the same age, thus yielding ties.
>I could code this with "brute force", but that would take a couple hundred
>lines of code.
>Does anyone have a simple or elegant solution?
>Thanks in advance
>Senior Research Associate
>2 World Trade Center
>NY NY 10048