Provide example data in the form of a datastep and what the desired result is. Do you need a report that people read or a data set to feed another analysis process?
Since you are talking about date intervals the process will almost certainly work better if your date information is in the form of a SAS date valued variable an not character.
That's an interesting problem ... will have to think about it ... calculating diffs (=date_diff) between dates (in weeks) and setting txn_freq to the lowest value found for each customer_id ... formatting date_diff to show the expected text ... just some initial thoughts.
I see how A is once per month, and B is once per week, given the intervals between records. But there is no interval for C since it has only one record. So why is it termed "2 months once"?
State your rules.
You now have 2 C records, one in April and one in June. So how are we to know why you call this once per 3 months?
Please clearly state the criteria you use to infer each possible frequency. For an effective coding solution, a clear specification of the requirements is needed.
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.
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.