Hi, I have a data that has three variables namely Department, Totalsales and Date. I have many departments. Each day, new sales adds to the the Totalsales column and shows the total until that specific day. I want to know how many new sells there are each day by subtracting one day's totalsales from the next day's totalsales and put it in a new column. Therefore at last I will have four columns (Department, Totalsales, Date, and newsells). I sorted the data by Department and Date. I tried to work using do loop but lost on the way. Can anybody assist me with this. I am posting a hypothetical data similar to my data here. Thank you Data All; Input Department$ Totalsales Date DDMMYY8.; format Date yymmdd10.; cards; D 45 01/03/19 D 47 02/03/19 D 51 03/03/19 D 55 04/03/19 B 35 01/03/19 B 37 02/03/19 B 43 03/03/19 B 42 04/03/19 E 59 03/03/19 E 64 04/03/19 M 45 01/03/19 M 50 02/03/19 M 55 03/03/19 M 56 04/03/19 M 59 05/03/19 M 59 07/03/19 M 59 06/03/19; run; I want new sales for each department in the first column.
... View more