BookmarkSubscribeRSS Feed
new_sas_user_4
Obsidian | Level 7

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 !!

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
PeterClemmensen
Tourmaline | Level 20

Do you want to create a new data set or Is this for reporting purposes?

new_sas_user_4
Obsidian | Level 7

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
;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 362 views
  • 0 likes
  • 3 in conversation