The SAS Output Delivery System and reporting techniques

Date Difference between two datasets

Reply
Occasional Contributor
Posts: 19

Date Difference between two datasets

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)

Grand Advisor
Posts: 9,740

Re: Date Difference between two datasets

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.

Occasional Contributor
Posts: 19

Re: Date Difference between two datasets

Sorry for that!

Medicaid_id is the common column in both the datasets.

Grand Advisor
Posts: 9,740

Re: Date Difference between two datasets

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.

Post a Question
Discussion Stats
  • 3 replies
  • 325 views
  • 0 likes
  • 2 in conversation