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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.