I would like to know the logic for extracting transactions occurred with in 10 min , i have date, time with seconds, credit card and amount variables.
Show us a portion of the data. Follow these instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/
Also, describe the logic you want to use in more detail. Within 10 minutes of what?
I am sorry unfortunately i cannot share the data.
I have different credit card transactions at particular merchant. I would like to check from first transaction with in 10 minutes of time how many transaction happen irrespective of first transaction time.
Make up some data, in the exact same format as the real data.
I have different credit card transactions at particular merchant. I would like to check from first transaction with in 10 minutes of time how many transaction happen irrespective of first transaction time.
This still is vague in my mind, and can be interpreted differently by different people. Provide a few representative examples (plural) in your fake data set and explain the desired output.
The following data steps first create some datetime values for a few IDs at random intervals in minutes.
The second then shows how to determine the interval of a given datetime value from the first one.
You would use your account information in place of ID and likely requires sorting by the account information and the datetime of the transaction.
If you do not have a datetime value, which you will need, then the code will show how to add time values in hour minute seconds, if separate values, to a date.
data example; do id = 1, 2, 3; do date='11Jul2020'd, '12Jul2020'd; hour = rand('integer',1,15); min = rand('integer',1,18); sec = rand('integer',1,53); datetime= dhms(date, hour,min,sec); output; do i= 1 to 10; rmin= rand('integer',1,15); datetime = intnx('minute',datetime,rmin); output; end; end; end; format datetime datetime18.; keep id datetime; run; data want; set example; by id; retain firsttime; if first.id then firsttime=datetime; interval = intck('minute',firsttime,datetime,'C'); format firststime datetime18.; label interval="# minutes from first record for id"; run;
Set a flag for the interval value of interest to count as needed.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.