| Date: | Thu, 10 Nov 2005 06:06:51 -0500 |
| Reply-To: | Felix Momsen <fmomsen@FONI.NET> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Felix Momsen <fmomsen@FONI.NET> |
| Subject: | matching observations |
| Content-Type: | text/plain; charset=ISO-8859-1 |
Dear All,
Could you possibly help me on the following SAS programming problem?
From the original data set
data original;
input a b c d e f: $CHAR1.;
cards;
1 6 4 4 1 X
2 6 4 4 3 O
3 6 4 4 5 X
4 6 4 9 0 X
5 6 4 9 1 O
I want to create the new data set:
2 6 4 4 1 X
5 6 4 4 1 X
5 6 4 4 5 X
5 6 4 9 0 X
The new data set consists of the X (variable f) obs from the original data
set that have been matched to the O obs (variable f) in the original data
set according to certain rules (see below). Additionally, variable a of
each of the X obs in the new data set reveals which O obs it’s been matched
to.
What are the rules for matching X to O obs in the original data set? In
order to match the X with the O obs,
1. the X obs must have an exact match in b and c with the O obs AND
[2. the X obs must have either a smaller d value than the O obs OR
3. the X obs must have the same d value and a smaller e value than the O
obs]
In the original data set, let’s take the first O obs, i.e. obs 2. Obs 1
satisfies conditions 1 and 3, the other X obs only satisfy condition 1
relative to obs 2, so obs 1 is the only X obs that’s matched to the first O
obs, i.e. obs 2. It ends up in the new data set.
In the original data set, let’s take the other O obs. All X obs satisfy
condition 1, obs 1 and 3 also satisfy condition 2, obs 4 also satisfies
condition 3, so all three X obs are matched to obs 5 and end up in the new
data set.
Please do let me know if something is unclear or if you need more
information.
I greatly appreciate your help!
Best wishes,
Felix
|