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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.