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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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