Hi everyone.
I want to get the missing information in var1 from var2.
Sometimes var1 already has the information (e.g. inputs 1 and 4). But sometimes information for both var1 and var2 are not missing. Can be similar (e.g. input3) and dissimilar (e.g. input5). In case of dissimilar information, the information in var1 is always selected.
The data looks like this.
data ddd;
input ID var1 $ var2 $;
cards;
1 a .
2 . b
3 c c
4 d .
5 e f
;
run;
I would like a new column (new_var) to be added to the file to look like this.
input new_var
1 a
2 b
3 c
4 d
5 e
Thanks for your help.
If var1 and var2 are character, use function coalescec:
new_var = coalescec (var1, var2) ;
If var1 and var2 are character, use function coalescec:
new_var = coalescec (var1, var2) ;
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.