Hello. This Question has 2 steps:
I've a dataset, Table A with a variable, 'dist' which may have incorrect values. and have added a new variable 'dist_orig' which has the updated values.
However, 'dist_orig' only has updated values for some but not all observations (i.e, some are missing). Therefore I don't want to overwrite 'dist' with missing values in 'dist_orig';
I want to retain values of 'dist' for which I"m missing values in 'dist_orig'.
The ulitmate goal is to update the variable 'dist' with the values in dist_org.
I know how to do it if I divide Table A into 2 datasets and use the UPDATE statement.
But, how do you update 'dist' with values in 'dist_orig' if they're in the same dataset?
if both variables are numeric:
dist=coalesce(dist_org,dist);
or they are Char:
dist=coalescec(dist_org,dist);
Check docs for details.
Haikuo
Update:
deleted.
if both variables are numeric:
dist=coalesce(dist_org,dist);
or they are Char:
dist=coalescec(dist_org,dist);
Check docs for details.
Haikuo
Update:
deleted.
Thank you very much!!![]()
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.