Hey everybody
I'm working with claims data, where each patient has multiple rows. I would now like to create a new variable with a yes or no (1/0) per patient.
This is my exercise data:
data exercise;
input patient medication$ expensive no_rows;
cards;
1 a 1 1
1 b 0 1
1 a 1 1
2 c 0 1
2 d 0 1
2 a 1 1
3 b 1 1
3 a 1 1
3 c 0 1
4 a 1 1
5 b 1 1
6 d 0 1
6 d 0 1
;
run;
Now you can see, that I coded each medicine as expensive yes or no (1/0). I would like to know how I can add a variable that tells me if the patient has an expensive medicine.
As a table:
Patient | Medication | expensive | no_row | exp_pat |
1 | a | 1 | 1 | 1 |
1 | b | 0 | 1 | 1 |
1 | a | 1 | 1 | 1 |
2 | c | 0 | 1 | 1 |
2 | d | 0 | 1 | 1 |
2 | a | 1 | 1 | 1 |
3 | b | 1 | 1 | 1 |
3 | a | 1 | 1 | 1 |
3 | c | 0 | 1 | 1 |
4 | a | 1 | 1 | 1 |
5 | b | 1 | 1 | 1 |
6 | d | 0 | 1 | 0 |
6 | d | 0 | 1 | 0 |
Thank you for your answers and kind regards,
Nina