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
ALABAMA | AUTAUGA | 1.01473 |
ALABAMA | BALDWIN | 19.33969 |
ALABAMA | BARBOUR |
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.