I was working on a data where a table has 3 columns in which some of the column values are missing for example:
Now, I want to achieve something like this. Where LC_CODE is not provided we pick from LG_CODE and if LG_CODE is not provided we pick from referral code. And if we don't have any values for any of the columns we just leave it as blank.
So the desired output should be something like this as below
Something LIKE this
Data FIN_EMP_CODE;
set MR7;
FIN_EMP_CODE = ;
if('LC Code'.MR7 NE . then 'LC Code'N = FIN_EMP_CODE);
else if ('LG Code'.MR7 NE . then 'LG Code'N = FIN_EMP_CODE);
else ('Referal Code'N.MR7 NE . then 'Referal Code'N = FIN_EMP_CODE);
run;
Can someone suggest what should I do to achieve this. Please, HELP!!!
data want;
set have;
ref_code=coalesce(lc_code,lg_code);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.