Greetings All,
I've been scratching my head at the below for some time, hoping someone can point me in the right direction.
I have a daily transactional dataset with gaps. I want to see whether a product with a reference price "websiteprice" of $X on date T had an actual sold price "actualsoldprice" $Y >= $X for at least 10% of previous T – 90 days. In other words, for each transaction where "sale_at_or_above_refprice" == 1, we need to count how many times the actual sold price for prior transactions (of a given product) within the previous 90 days met or exceeded that transactions reference price. I have included first step results that I am looking for in the "wanted" column.
My data is as follows,
Thank you in advance,
Adrian
I've been scratching my head at the below for some time, hoping someone can point me in the right direction.
I have a daily transactional dataset with gaps. I want to see whether a product with a reference price "websiteprice" of $X on date T had an actual sold price "actualsoldprice" $Y >= $X for at least 10% of previous T – 90 days. In other words, for each transaction where "sale_at_or_above_refprice" == 1, we need to count how many times the actual sold price for prior transactions (of a given product) within the previous 90 days met or exceeded that transactions reference price. I have included first step results that I am looking for in the "wanted" column.
My data is as follows,
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str9 orderdate str16 productcode str10 productcategory byte(websiteprice actualsoldprice sale_at_or_above_refprice var7 wanted) "3-Jan-20" "MZZ32819-564-282" "Mens Jeans" 40 25 . . . "8-Jan-20" "MZZ32819-564-282" "Mens Jeans" 40 40 1 . . "12-Jan-20" "MZZ32819-564-282" "Mens Jeans" 40 40 1 . 1 "12-Sep-20" "MZZ32819-564-282" "Mens Jeans" 40 28 . . . "18-Sep-20" "MZZ32819-564-282" "Mens Jeans" 40 24 . . . "20-Sep-20" "MZZ32819-564-282" "Mens Jeans" 50 30 . . . "27-Sep-20" "MZZ32819-564-282" "Mens Jeans" 50 25 . . . "11-Oct-20" "MZZ32819-564-282" "Mens Jeans" 40 20 . . . "19-Oct-20" "MZZ32819-564-282" "Mens Jeans" 35 24 . . . "2-Nov-20" "MZZ32819-564-282" "Mens Jeans" 20 20 1 . 6 "2-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 7 "4-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 8 "7-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 9 "7-Nov-20" "MZZ32819-564-282" "Mens Jeans" 20 20 1 . 7 "9-Nov-20" "MZZ32819-564-282" "Mens Jeans" 20 20 1 . 8 "11-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 12 "12-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 13 "14-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 14 "15-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 15 "18-Nov-20" "MZZ32819-564-282" "Mens Jeans" 14 14 1 . 16 "24-Nov-20" "MZZ32819-564-282" "Mens Jeans" 20 20 1 . 9 end
Adrian
Comment