| 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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.