Hi everyone,
Could you please help me calculate a row for MTD calculations
Eg: If I am at Day_no 4 , I want the first row to say Audi MTD 720 18 1620 62
Below is the sample data:
data raw_Data;
length brand $4;
input brand Day_No CM_Units CM_sales PM_Units PM_sales;
datalines;
Audi 1 100 2 200 3
Audi 2 200 10 400 50
Audi 3 20 2 500 3
Audi 4 400 4 520 6
;
Thank you !!
Eg: If I am at Day_no 4 , I want the first row to say Audi MTD 720 18 1620 62
Do you mean you want the 4th row to say Audi MTD 720 18 1620 62
Why does it have to be in any particular row?
Do you want to create a new data set or Is this for reporting purposes?
It is for reporting purposes...I would eventually use it in proc report
In the proc report, the first row will be "MTD"
and if Its day_no 4 , the PM_units and PM_sales might still have numbers, but I want the MTD based on if the CM_Sales and CM_units are non-zero.
data raw_Data;
length brand $4;
input brand Day_No CM_Units CM_sales PM_Units PM_sales;
datalines;
Audi 1 100 2 200 3
Audi 2 200 10 400 50
Audi 3 20 2 500 3
Audi 4 400 4 520 6
Audi 5 0 0 566 2
Audi 6 0 0 250 25
Audi 7 0 0 200 2
Audi 8 0 0 200 2
;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.