BookmarkSubscribeRSS Feed
Quartz | Level 8
I have ICD 10 codes from 1 to 10 listed.
I would like to combine all codes values if any listed ICD 10 codes start with A. How can I do that? Thank you.

Example fake data:

Code1 code2 …code10
H25 G45
J257 D467 A56
A46 A56
F35 D456 A456 Y366

Wanted data would be keep all values when start with A.
Super User Tom
Super User

Here is basic logic for looping over an array or variables and checking if ANY of them meet some condition.

First set the overall result to FALSE.  Then loop until you run out of elements or you find one that it TRUE.

data want;
   set have;
   array code [10] ;
   any_a = 0;
   do index=1 to dim(code) while (not any_a);
      any_a = code[index] =: 'A';
   if ANY_A then output;
Super User

You should explain what you mean by "combine". If you mean to place multiple values into one variable that is likely to become a variable that is extremely difficult to work with.


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3 in conversation