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
;

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