BookmarkSubscribeRSS Feed
ashwini2
Fluorite | Level 6

Hello All,

 

I have my first dataset which has minimum date(dataset name= agency_based) (column name=min_date)

 

Second dataset has maximum date(dataset name= self_directed) (column name=max_date)

 

And i am trying to find difference between these two dates.

 

Can somebody please help me with this please.

 

Format of the dates is date9. (ddmmmyyyy)

3 REPLIES 3
ballardw
Super User

It may help to describe the contents of your datasets more completely. I would think that the Min_date and Max_date are related to something such as an account name, location, person, activity. Then it would make sense to use that identifying information to link the datasets and then compare the date values.

ashwini2
Fluorite | Level 6

Sorry for that!

Medicaid_id is the common column in both the datasets.

ballardw
Super User

Now for an obnoxious question, does the same medicaid_id exist more than once in either of the files? If not then something like this

 

Proc sql;
   create table matched as
   select agency_based.*, self_directed.*, (self_directed.Max_date - agency_based.Min_date) as date_dif
   from  agency_based left join self_directed
      on agency_based.Medicaid_id =  self_directed.Medicaid_id;
quit;

Or sort by data sets and then do a Merge by medicaid_id.

 

If there are duplicates of the Id variable then there should be more information to link on such as service or provider or something that makes sense that the min and max are related.

 

One might also ask if both of these sets are derived from a common base data set? There may be some other approaches if that is the case that would not require creating multiple datasets but allows the same comparison.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1037 views
  • 0 likes
  • 2 in conversation