I have mentioned below dataset in SAS. Table-1 Sr No PRODUCT ON SALE DATE OFF SALE DATE SELL_PRICE 1 P1 01-Jan-18 03-Jan-18 84 2 P1 02-Jan-18 06-Jan-18 93 3 P1 04-Jan-18 10-Jan-18 46 4 P1 08-Jan-18 10-Jan-18 14 5 P1 01-Jan-18 01-Jan-18 15 6 P2 01-Jan-18 07-Jan-18 84 7 P2 03-Jan-18 04-Jan-18 93 8 P2 07-Jan-18 09-Jan-18 46 9 P2 04-Jan-18 08-Jan-18 14 10 P2 03-Jan-18 04-Jan-18 15 I have a product list(in this case P1 and P2) and there are many date range for the same product with the different price. The time range can overlap each other for the same product. My task is to make a dataset which contains a date range which will be the min of 'ON SALE DATE' and the max of ''OFF SALE DATE". so for the product, P1 date range will be 1-Jan-2018 to 10-Jan-2018. and for the product, P2 date range will be 01-Jan-2018 to 09-Jan-2018. and the price will come which will be minimum for that date. so the dataset will look like below one... Table-2 Sr No PRODUCT Date SELL_PRICE 1 P1 01-Jan-18 15 2 P1 02-Jan-18 84 3 P1 03-Jan-18 84 4 P1 04-Jan-18 46 5 P1 05-Jan-18 46 6 P1 06-Jan-18 46 7 P1 07-Jan-18 46 8 P1 08-Jan-18 14 9 P1 09-Jan-18 14 10 P1 10-Jan-18 14 11 P2 01-Jan-18 84 12 P2 02-Jan-18 84 13 P2 03-Jan-18 15 14 P2 04-Jan-18 14 15 P2 05-Jan-18 14 16 P2 06-Jan-18 14 17 P2 07-Jan-18 14 18 P2 08-Jan-18 14 19 P2 09-Jan-18 46 so if you check the price for P1 on 1-Jan-2018, there are two prices mentioned for this first table-Row-1, the price for P1 is 84 First table-Row-Row-5 the price for P1 is 15. hence the final price for P1 for 01-Jan-2018 will be 15 which is minimum between (84,15). check Table-2 and Row-1. How to write a SAS code for this.
... View more