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) ;
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.