I am working with a large dataset that includes a Race/Ethnicity variable (ePatient_14). As I merge several years worth of data using a unique id (PcrKey), I have been reshaping each dataset and generating dummy variables to capture each race/ethnicity value. I encountered a problem with the latest year and noted observations within i(PcrKey) with the same value of j(ePatient_14), which are really duplicates. I cannot figure out how to flag these repeated values so I can drop them from the dataset. Does anyone know how to address this without just dropping all duplicate values? Thanks!
In the example below, ops 118172608 has two values for Race, but they are the same values (which makes it a true duplicate). I need to their be able to flag the duplicate value so I can drop it or I may just have to drop all duplicate values and work with the first/preferred value.
In the example below, ops 118172608 has two values for Race, but they are the same values (which makes it a true duplicate). I need to their be able to flag the duplicate value so I can drop it or I may just have to drop all duplicate values and work with the first/preferred value.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double PcrKey str10 ePatient_14 byte dup 118172598 "2514005" 0 118172608 "2514011" 1 118172608 "2514011" 1 118172611 "2514011" 0 118172618 "2514011" 0 118172621 "2514011" 0 118172625 "2514011" 0 118172628 "2514005" 0 118172629 "2514005" 0 118172634 "2514005" 0 118172636 "2514011" 0 end

Comment