BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Zakir
Obsidian | Level 7

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16
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;
Thanks,
Jag

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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;

 

--
Paige Miller
Jagadishkatam
Amethyst | Level 16
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;
Thanks,
Jag
Zakir
Obsidian | Level 7

Thank you so much Jagadishkatam. 

Best

Zakir

Ksharp
Super User
data want;
merge have have(keep=exe_name ceoann rename=(ceoann=new_ceoann) where=(new_ceoann is not missing));
by exe_name;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 644 views
  • 3 likes
  • 4 in conversation