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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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