BookmarkSubscribeRSS Feed
MadCowKilla
Calcite | Level 5
Hello,
I'm joining 4 tables using a left join. 1 table has Salary by quarter (left table) and the other 3 tables have different expenses by quarter. I want to join them so that I could calculate:

Gross margin = Salary - Expesne1 - Expense2 - Expense3

My gross margin works great if I have the same quarter match in all 4 tables.

My gross margin turns blank whenever I don't have a match for that quarter in all 4 tables. It lists the Revenue and the expenses but it won't calculate gross margin.

How do I fix it?

thanks!
2 REPLIES 2
DBailey
Lapis Lazuli | Level 10
Gross_margin = coalesce(Salary,0) - Coalesce(Expense1,0) - Coalesce(Expense2,0) - coalesce(Expense3,0)
MadCowKilla
Calcite | Level 5
This works great.

Thank you very much.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 764 views
  • 0 likes
  • 2 in conversation