BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

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?

1 REPLY 1
LinusH
Tourmaline | Level 20

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 b.date between a.date and a.date -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

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
  • 1 reply
  • 713 views
  • 3 likes
  • 2 in conversation