BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello All-

I have one row per patient and for each row I have up to 10 ICD codes (each code is a variable/column, e.g. ICD1, ICD2, ..., ICD10) and corresponding ICD text for each of the codes. I am interested in identifying, for each patient, the ICD9 code(s) that match any of the codes that I have from a master list of codes. Then I want to create a new variable, for each row, that contains the codes that matched along with the corresponding text.

Is this an issues that can be managed using an array?

Thanks in advance-
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
An array could be used to parse through the ICD codes and using a SAS format and a PUT function to compare each ICD variable against your master list of codes. Then as you process through the ICD codes, if you find a match by using the test, such as

MATCH = PUT(ICD,$icd_master.);

Then you append each of the matching codes to a new combined-matching-values variable that are in your master list.

So, I prefer to build the $icd_master format with SAS PROC FORMAT, and as shown using the PUT function to test for a match. Using a SAS format for the master list is more flexible for DATA step processing in my opinion.


Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Thank you Scott for the suggestions! I will post again should I run into further issues.

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