BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Wolverine
Pyrite | Level 9

I have Medicaid data, and there is a separate line for the category of each diagnosis (DX_cat) given at a visit to a doctor.  I want to combine all of those diagnoses into a single line for each visit.  Keep in mind that this requires combining with respect to ID (Encrpt_ID) AND date of service (ClaimDOS).  I've found various methods to combine with respect to a single variable, but none for multiple variables.  I'm guessing that SQL would be best for this, but I'm open to whatever works.  I believe that the number of diagnoses that can be given at a single visit is limited to 9.

The input data looks like this:

Encrpt_IDClaimDOSDX_cat
123

1-10-14

2
1231-10-145
1232-1-142
1232-1-145
1232-1-146
4561-10-147
4561-10-1410
7896-1-141

The output should look like this:

Encrpt_IDClaimDOSDX_cat_1DX_cat_2DX_cat_3
1231-10-1425
1232-1-14256
4561-10-14710
7896-1-141
1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

proc transpose data=have out=want prefix=DX_cat_;

  by Encrpt_ID ClaimDOS notsorted;

  var DX_cat;

run;

View solution in original post

2 REPLIES 2
stat_sas
Ammonite | Level 13

proc transpose data=have out=want prefix=DX_cat_;

  by Encrpt_ID ClaimDOS notsorted;

  var DX_cat;

run;

Wolverine
Pyrite | Level 9

That works nicely -- thank you!  :smileygrin:

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2119 views
  • 0 likes
  • 2 in conversation