Hello all,
I have a dataset with variables called drug1-drug25. In them, the same drug type can be identified multiple times per row in the data. I need to keep the first occurrence of the drug type, but set all subsequent occurrences to missing. For example, in the data sample below, the first row has 3 "Codeine." I need to keep the first occurrence of "Codeine" and set the remaining two occurrences to "".
As always, any help with code would be greatly appreciated!
I have a dataset with variables called drug1-drug25. In them, the same drug type can be identified multiple times per row in the data. I need to keep the first occurrence of the drug type, but set all subsequent occurrences to missing. For example, in the data sample below, the first row has 3 "Codeine." I need to keep the first occurrence of "Codeine" and set the remaining two occurrences to "".
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str33 drug1 str34(drug2 drug3) "Codeine" "Codeine" "Codeine" "6-MAM" "6-MAM" "6-MAM" "Cocaine" "Cocaine" "Cocaine" "Benzoylecgonine" "Benzoylecgonine" "Benzoylecgonine" "Codeine" "Codeine" "Codeine" "Methamphetamine" "Methamphetamine" "Methamphetamine" "THC" "THC" "Oxycodone" "Morphine" "Morphine" "Alprazolam" "Cocaine" "Cocaine" "Oxycodone" "Amphetamine" "Morphine" "Morphine" "Methamphetamine" "Hydrocodone" "Methamphetamine" "MDA" "MDMA" "Methamphetamine" "6-MAM" "6-MAM" "Morphine" "Benzoylecgonine" "Benzoylecgonine" "Benzoylecgonine" "6-MAM" "6-MAM" "6-MAM" end
Comment