I have a dataset that is structured like this: Person Demographic1 Age Diagnosis1 SecondaryDiagnosis SecondaryDiagnosisPosition Bob Male 45 424.0 250.1 2 Bob Male 45 424.0 V89.1 3 Bob Male 45 424.0 715.0 4 Jane Female 22 492.11 V25 2 Roger Male 10 720.1 etc etc... I would like to create a dataset like this: Person Demographic1 Age Diagnosis1 diagnosis2 diagnosis3 diagnosis4.....etc Bob Male 45 424.0 250.1 V89.1 715.0 Jane Female 22 492.11 V25 Roger Male 10 720.1 etc... My first thought was to create a new variable for each secondary diagnosis position (so... diagnosis2, diagnosis3, etc) and have it store the associated diagnosis code. I used this code: data x; set data y; diagnosis3 = .; IF(secondarydiagnosis) =3 then diagnosis3= secondarydiagnosis; run; I tried this, but it didn't quite work- it errors out because of the v-codes (character data) inherent in ICD-9 coding. It seems like when I created the new variable, it was automatically created as a numeric variable, when it should've been a character variable. I've tried to switch it to a character, but when I do that, I end up deleting my entire dataset. data x; diagnosis2_char = put(diagnosis2, 6.) drop diagnosis2; rename diagnosis2_char = diagnosis2; run; Primary question: How should I be creating my new variables to get around this issue with the V-codes without deleting my dataset? Secondary question: I'm not sure that I've chosen the most efficient way to get from the dataset structure I have to the dataset structure that I want- so if there are comments on that, it would be appreciated as well- but my primary problem is the character/ numeric situation. Thank you.
... View more