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?
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?
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?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.