Dear All,
Good day. I have the following dataset where I am unable to fill the missing strings. Any help would be highly appreciated.
Exe_name ceoann gvkey year
Bob CEO 1045 1992
Bob CEO 1045 1993
Bob 1045 1994
David 1004 1992
David CEO 1004 1993
David CEO 1004 1994
James 9999 1992
James CEO 9999 1993
James 9999 1994
Thanks in advance.
Kind regards,
Zakir
Proc sort data=have;
by exe_name descending ceoann;
run;
data want;
set have(rename=(ceoann=_ceoann));
by exe_name descending _ceoann;
retain ceoann;
if first.exe_name then ceoann=_ceoann;
run;
This seems like a very unusual example. It seems like you want to place CEO everywhere it is missing. Is that what you want? If so ...
data want;
set have;
if missing(ceoann) then ceoann='CEO';
run;
Proc sort data=have;
by exe_name descending ceoann;
run;
data want;
set have(rename=(ceoann=_ceoann));
by exe_name descending _ceoann;
retain ceoann;
if first.exe_name then ceoann=_ceoann;
run;
Thank you so much Jagadishkatam.
Best
Zakir
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.