I need some help with my sas coding. I have a dataset with admissions to hospitals, where each admission is registered as one observation. That means that one person can appear in the dataset more than once and some people have up to a 100 admissions. We can order the dataset so that all admissions that belongs to one person is numbered and ordered by the admission date.
If a person has had an admission on date x, we would now like to delete any following admissions(observations) that appear within 4 days after date x. Do any you know an easy way to do this?
You'll have to confirm that this handles things (cases) as you want, but it should at least get you started (assumes that your data has been sorted). Note what happens with patient number 4 (where I reset the "base" date), and what happens with patient 1 where 16FEB09 is NOT deleted --- I'm not sure if this is what you'd want to happen. If you'd want 16FEB09 deleted in a case like this (where 15FEB09 was already deleted), then the code would have to be revised.
Second I do not understand whether this sas coding only compare the time span between the first admission and the following admissions. Or if it compares the time span between all admissions in the dataset.
It isn't really an error message, but just a write to the LOG. You can eliminate that by dropping the statement that begins with "PUT". It was used for diagnostic information only.
The comparison isn't just to the first admission, but neither is it comparing all possible combinations. It starts out comparing to the first admission, but then resets the comparison date whenever a new admission date is encountered (for a given patient) that was not subject to deletion.
Please look at what happens for my made-up patient number one, and note what records are dropped versus kept. I'm really not sure what outcome you'd actually want to have in that case. The 16Feb09 wasn't dropped because it was more than 4 days from the 11th, but if the 15th hadn't been deleted, then the 16th would have been within 4 days of the 15Feb and therefore possibly subject to elimination.
Did you want to do comparisons between all admissions within a patient?
I don't want to compare all admission dates for each patient. I have tried to illustrate what I want by an example:
Patient X has had the following admissions:
Ad 1: 11feb08
Ad 2: 13feb08
Ad 3: 16feb08
Ad 4: 18feb08
Ad 5: 25feb08
In this case, I would like to keep admission number 1 as the first admission and delete the admission on 13feb08. Then keep admission number 3 as the second admission and delete number 4 admission, since there is only 2 days between the second admission and this one. - So, what I would like to do is to change the "reference date" from admission date 1 to admission date 2.
Using straightforward DATA step processing, you can assign SAS variables as needed, and you can use the technique IF/THEN DELETE; (or the converse, IF/THEN OUTPUT; ) to subset your dataset observations.
I am aware of the if then - delete statements.
However, some of the persons in our dateset has up to 117 admissions, so the editor will be quite long using the if then statements. This is why I have asked for help. So - I would be very glad if anyone can help me with this.