DATA Step, Macro, Functions and more

dates difference

Super Contributor
Posts: 713

dates difference

There are two datasets A &B.The common field between them is cust_id.

Table A have the date filed in format 2013-09-26   and table B date filed in format 20130926

How to get records from table B  that are 30days prior to date in table A for the same cust id?

Super User
Posts: 5,888

Re: dates difference

First, when you say format, do you mean that the dates are stored as CHAR? If they are stored as SAS dates, the format doesn't matter in the join logic.

Join criteria:

a.cust_id = b.cust_id and between and -30

Be aware that you will be noted of that SAS can't optimize these kind of criteria, but if your data isn't too large, it shouldn't be a problem.

Data never sleeps
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation