I have a string variable consisting of CPT codes, which are medical codes for various procedures. Stata has a nice set of routines for handling ICD9 codes, but not CPT codes. In the SAS file version of this, which is the form in which we originally got the data, the string variables are labeled via Proc Format, e.g. a CPT code of “J507” might have a label of “MRI lower abdomen”. When I convert the file to Stata using Stat Transfer the string variables get no labels of course because Stata will not let you label a string.
I know that I can use encode to create a set of numeric codes corresponding to the string values with the original string values becoming labels. So, J507 becomes, say, numeric value 22 with label “J507.” But I need to get the original long labels attached to the numeric values so that 22 gets labeled as “MRI lower abdomen” or even better “J507 MRI lower abdomen.” I can do this by brute force my modifying the SAS code and changing it to label define statements but I suspect that someone else has faced this problem and I would appreciate any suggestions as to how to solve it efficiently.
I know that I can use encode to create a set of numeric codes corresponding to the string values with the original string values becoming labels. So, J507 becomes, say, numeric value 22 with label “J507.” But I need to get the original long labels attached to the numeric values so that 22 gets labeled as “MRI lower abdomen” or even better “J507 MRI lower abdomen.” I can do this by brute force my modifying the SAS code and changing it to label define statements but I suspect that someone else has faced this problem and I would appreciate any suggestions as to how to solve it efficiently.
Comment