BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
E_W
Calcite | Level 5 E_W
Calcite | Level 5

I have one dataset which is missing some coefficient data.

 

I have a separate dataset with a similar structure which contains much of the missing data, but when I left join them, I don't want it replacing the rows with existing coefficients. I only want the 2nd dataset's numbers to fill in the blank rows.

 

I've been trying out conditional proc SQL's, but nothing has worked so far. Any help would be appreciated.

 

Dataset1

State              City/Town      Coefficient

ALABAMAAUTAUGA1.01473
ALABAMABALDWIN19.33969
ALABAMABARBOUR 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Sounds like you want the COALESCE() function.

proc sql;
create table want as
select a.state
     , a.city
     , coalesce(a.coeff,b.coeff) as coeff
from a 
left join b
on a.state=b.state and a.city=b.city
;
quit;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Sounds like you want the COALESCE() function.

proc sql;
create table want as
select a.state
     , a.city
     , coalesce(a.coeff,b.coeff) as coeff
from a 
left join b
on a.state=b.state and a.city=b.city
;
quit;

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

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 817 views
  • 0 likes
  • 2 in conversation