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

I have a dataset that contains procedure codes ranging from 1 to 12 (cpt_code1-cpt_code12), that were performed on the same day. I need to search across these variables for specific codes that are related to a specific test being carried on on a patient.

The codes related to each procedure are listed below:

 

Test1: 81507, 84702

Test2: 84163, 84702, 76813

Test3: 82677, 84702, 86336
Test4: 82105, 84702, 86336, 82677


Note that  all the codes listed for each test need to exist in the same row (i.e.cpt_code1-cpt_code12) for that test to be valid. In other words, let's say for a specific person, their row only contains cpt code 81507, I wouldn't be able to classify them as receiving Test1 since cpt code 84702 is not included in that line.

 

I've tried searching previous forums (and reading about arrays) but I can't seem to find anything that matches my situation. 

 

Below is a snippet of what I have so far:

data work.example2;
length test_type $20.;
set work.example;
array acpt_code(1:12) cpt_code1-cpt_code12;
do i=1 to 12;
if acpt_code[i] in ('81507', '84702') then test_type="Test1";
end;
run;

I know the above code is not correct since I'm just telling SAS to search across the variables to see if at least one of the cpt codes exist, and I need to know that both codes exist in order for Test1 to be assigned as the test type (which is where I'm stuck).

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @kingsii24,

 

Just adapt the program code to the logic and search for those specific codes in the array (and not vice versa), for example:

if '81507' in acpt_code & '84702' in acpt_code then test_type="Test1";

 

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19

Show example input your HAVE data.

FreelanceReinh
Jade | Level 19

Hi @kingsii24,

 

Just adapt the program code to the logic and search for those specific codes in the array (and not vice versa), for example:

if '81507' in acpt_code & '84702' in acpt_code then test_type="Test1";

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 692 views
  • 0 likes
  • 3 in conversation