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? 


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1 reply
  • 353 views
  • 1 like
  • 2 in conversation