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?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.