Hi I am using Base SAS 9.3. I have a data file where one line of code is one patient visit. For diagnoses they are labeled (and sequenced) as dx1 dxtype1 dx2 dxtype2. Note that there are up to 25 occurrences of diagnosis codes (though not all will have data in all 25) and a diagnosis type only exists if there is a diagnosis in the same occurrence. What I want to do is search through the data and find the diagnosis that is the type of "M", make it the first occurrence and resequence all other diagnoses within the abstract after that.
data test_grp; input @1 AcctNo $4. @5 Dx1 $7. @12 DxTyp1 $1. @13 Dx2 $7. @20 DxTyp2 $1. @21 Dx3 $7. @28 DxTyp3 $1. @29 Dx4 $7. @36 DxTyp4 $1.;
cards; 0001T814 1 K650 M Y832 9 B962 3 0002T810 M D62 1 Y838 9 O021 3 0004A047 1 A047 2 J189 M I350 3 0005A401 3 I619 M J9609 2 Z515 1 0006Z548 M C61 3 G809 3 E669 3
run;
So in the case of acct# 0001, it should resequence to K650 M T814 1 Y832 9 B962 3. K650 will now be Dx1, M will be DxTyp1, T814 will be Dx2, DxTyp2 will be 1 and so on. Is this possible? Thanks very much.
... View more