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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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