BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abdulla
Pyrite | Level 9
GVKEYfyearEXECIDTITLEANN
002538200702158president & CEO
002538200802158president & CEO
002538200902158 
002538201002158 
002538201142441 
002538201242441chmn. & CEO
002538201342441chmn. & CEO

 

I want the following result

GVKEYfyearEXECIDTITLEANN
002538200702158president & CEO
002538200802158president & CEO
002538200902158president & CEO
002538201002158president & CEO
002538201142441 
002538201242441chmn. & CEO
002538201342441chmn. & CEO

can anyone help me with this? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Standard use case for RETAIN.

 

data want;
set have;
by GVKEY;

retain newTitle;

if not missing(titleAnn) then newTitle = titleAnn;

if first.GVKEY and missing(titleAnn) then call missing(newTitle);

run;

@abdulla wrote:
GVKEY fyear EXECID TITLEANN
002538 2007 02158 president & CEO
002538 2008 02158 president & CEO
002538 2009 02158  
002538 2010 02158  
002538 2011 42441  
002538 2012 42441 chmn. & CEO
002538 2013 42441 chmn. & CEO

 

I want the following result

GVKEY fyear EXECID TITLEANN
002538 2007 02158 president & CEO
002538 2008 02158 president & CEO
002538 2009 02158 president & CEO
002538 2010 02158 president & CEO
002538 2011 42441  
002538 2012 42441 chmn. & CEO
002538 2013 42441 chmn. & CEO

can anyone help me with this? 


 

View solution in original post

1 REPLY 1
Reeza
Super User

Standard use case for RETAIN.

 

data want;
set have;
by GVKEY;

retain newTitle;

if not missing(titleAnn) then newTitle = titleAnn;

if first.GVKEY and missing(titleAnn) then call missing(newTitle);

run;

@abdulla wrote:
GVKEY fyear EXECID TITLEANN
002538 2007 02158 president & CEO
002538 2008 02158 president & CEO
002538 2009 02158  
002538 2010 02158  
002538 2011 42441  
002538 2012 42441 chmn. & CEO
002538 2013 42441 chmn. & CEO

 

I want the following result

GVKEY fyear EXECID TITLEANN
002538 2007 02158 president & CEO
002538 2008 02158 president & CEO
002538 2009 02158 president & CEO
002538 2010 02158 president & CEO
002538 2011 42441  
002538 2012 42441 chmn. & CEO
002538 2013 42441 chmn. & CEO

can anyone help me with this? 


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 704 views
  • 1 like
  • 2 in conversation