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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1162 views
  • 0 likes
  • 2 in conversation