Hi there,
I have a dataset of patients with their medication history. Below, listed a sample dataset of 1084200 observations in my dataset. I have 20+ variables, but below listed are only four variables.
"medicine_code" defines the type of medicine and depends on the strength (ex: X medicine with 20 mg, 40mg strength); there may be several codes for one medicine. However, I'm only interested in a couple of "medicine_codes" (actually, there are 190 "medicine_codes" that I'm interested in), and I want to keep only the patients who have been on those interested medicines and drop the rest of the observations.
ex: if medicine_code=="61332"|medicine_code=="71293"
Highly appreciate if you can help me out to find a suitable command to get a subset of data fulfilling my condition.
Thank you in advance!
Thushani
input str11 Patient_id str1 gender str7 year_month_birth long medicine_code
"1" "M" "AUG1955" 73655
"1" "M" "AUG1955" 61332
"1" "M" "AUG1955" 71293
"1" "M" "AUG1955" 71586
"2" "M" "OCT1920" 61332
"2" "M" "OCT1920" 73655
"2" "M" "OCT1920" 73655
"3" "M" "DEC1928" 61332
"3" "M" "DEC1928" 66400
"3" "M" "DEC1928" 73422
"3" "M" "DEC1928" 67117
"4" "F" "JAN1929" 71293
"4" "F" "JAN1929" 73518
"4" "F" "JAN1929" 73787
"4" "F" "JAN1929" 73605
"5" "M" "MAY1956" 61839
"6" "M" "AUG1930" 72661
"6" "M" "AUG1930" 61332
"6" "M" "AUG1930" 61333
"6" "M" "AUG1930" 61335
"7" "F" "FEB1951" 71293
"7" "F" "FEB1951" 68544
"8" "M" "JUN1938" 71293
"8" "M" "JUN1938" 73033
"8" "M" "JUN1938" 61332
"8" "M" "JUN1938" 73775
I have a dataset of patients with their medication history. Below, listed a sample dataset of 1084200 observations in my dataset. I have 20+ variables, but below listed are only four variables.
"medicine_code" defines the type of medicine and depends on the strength (ex: X medicine with 20 mg, 40mg strength); there may be several codes for one medicine. However, I'm only interested in a couple of "medicine_codes" (actually, there are 190 "medicine_codes" that I'm interested in), and I want to keep only the patients who have been on those interested medicines and drop the rest of the observations.
ex: if medicine_code=="61332"|medicine_code=="71293"
Highly appreciate if you can help me out to find a suitable command to get a subset of data fulfilling my condition.
Thank you in advance!
Thushani
input str11 Patient_id str1 gender str7 year_month_birth long medicine_code
"1" "M" "AUG1955" 73655
"1" "M" "AUG1955" 61332
"1" "M" "AUG1955" 71293
"1" "M" "AUG1955" 71586
"2" "M" "OCT1920" 61332
"2" "M" "OCT1920" 73655
"2" "M" "OCT1920" 73655
"3" "M" "DEC1928" 61332
"3" "M" "DEC1928" 66400
"3" "M" "DEC1928" 73422
"3" "M" "DEC1928" 67117
"4" "F" "JAN1929" 71293
"4" "F" "JAN1929" 73518
"4" "F" "JAN1929" 73787
"4" "F" "JAN1929" 73605
"5" "M" "MAY1956" 61839
"6" "M" "AUG1930" 72661
"6" "M" "AUG1930" 61332
"6" "M" "AUG1930" 61333
"6" "M" "AUG1930" 61335
"7" "F" "FEB1951" 71293
"7" "F" "FEB1951" 68544
"8" "M" "JUN1938" 71293
"8" "M" "JUN1938" 73033
"8" "M" "JUN1938" 61332
"8" "M" "JUN1938" 73775
Comment