Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: How can I get the second last non-missing value?


From   duygu yıldırım <dyg_math@hotmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: How can I get the second last non-missing value?
Date   Wed, 12 Jun 2013 23:27:09 +0300

Hello everyone, 

I use a cross-sectional individual level data set. I want to ask if there is a way that I can create a variable which consists the second last non-missing value within observations? 

for example; 

id v1 v2 v3 v4 v5 
 1 1  2  3  .  . 
 2 1  2  .  .  . 
 3 1  2  3  4  . 

So the variable that I want to create is; 

id  v6 
1   2 
2   1 
3   3 

I can get the last non-missing value within observation by using the rowlast command, but I also need the one just before the last one. 

Thank you all very much for any help, 

Duygu. 		 	   		  

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index