BookmarkSubscribeRSS Feed

Hi,

 

I am really stuck on this and I have figured this out manually before via pivots and whatnot but I'm blanking out on this now.

 

What is the way to do this in SAS? Here is an example of my data:

 

ID          Procedure Code        Date of Service

567            93880                      1/1/2020

567            93306                      1/1/2020

567            93880                      3/1/2020

567            93306                      3/1/2020

689            93880                      2/1/2020

689            93306                      2/1/2020

 

I would only want to bring in those where the ID uses BOTH codes and happened on the same day so that I can then total the dollars associated with those people.

 

Please help if you have any ideas. Thank you

 

     

2 REPLIES 2
andreas_lds
Jade | Level 19

Please post what you expect as result from the data you have posted.

And some more questions:

- is date_of_service a sas-date?

- how many different values are stored in procedure_code? just two?

Tom
Super User Tom
Super User

Try this in PROC SQL.

create table want as 
  select * from have
  group by ID, date_of_service
  having max(case when (procedure='93880') then 1 else 0) = 1
     and max(case when (procedure='93306') then 1 else 0) = 1
;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 615 views
  • 0 likes
  • 3 in conversation