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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.