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
;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.