- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dataset: I have last 3 months transaction data. If customer is doing atleast one transaction every week
I want to put the freq as 'weekly once'. If he is doing some transaction two week once, then freq should be '2 weeks once
If he is doing transaction monthly once, then it should be 'monthly once',
' 2 months once' , ' 3 months once, etc.
If one month the frequency is monthly once and on another month, if it is 2 weeks once, the freq should be lowest one ' 2 weeks once.
Customer_Id txn_date txn_id
A 13/5/2018 01
A 12/6/2018 02
B. 1/6/2018. 03
B. 8/6/2018. 04
B 15/6/2018 05
C. 1/4/2018. 06
Now I want the output to be like
Customer_id txn_freq
A monthly once
B weekly once
C 2 months once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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"?
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mkeintz, You are correct. Dataset should look like below. For the above dataset,C's freq should be 3 months once.
A 13/5/2018 01
A 12/6/2018 02
B. 1/6/2018. 03
B. 8/6/2018. 04
B 15/6/2018 05
C. 1/4/2018. 06
C 1/6/2018. 07
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------