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:

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register 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
  • 1278 views
  • 0 likes
  • 2 in conversation