The dataset is relevant to the output. The logic is firstly record the name of the customer, then count how many sales were made by the customer (can be by the number of date or number of sales made). Finally, compute the days between last sales and 31 Dec 2023. Below are the code im trying but seems not work: data Totalsales; input name $quote20. @; format var1 date11.; s1 = substr(name,1,1); If ('A' <= s1 <= 'Z') then do; if _n_ ^=1 then output; input var1 sales; end; if endfile=1 then output; datalines; "David Wong" 1/Aug/2023 13200 "Brian Leung" 15/Sep/2023 23450 10/Sep/2023 33000 "Mary Chan" 3/Jul/2023 45600 20/Aug/2023 37800 1/Dec/2023 21500 30/Aug/2023 42000 "John Tam" 12/Sep/2023 35000 ; run;
... View more