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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: Subtract Closest Cell Which has A Value


From   Lisa Wang <lhwang0925@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Subtract Closest Cell Which has A Value
Date   Fri, 26 Oct 2012 13:41:46 +1100

Dear all,

I have another question. I have two columns of values - variables A
and B to make it simple. I would like to A-B in a new column C;
however, column B has a lot of missing values (.), so it doesn't seem
that simple. Variable A is complete, so no missing data. I would like
Stata to find the nearest cell (data is already sorted by column D)
with a value in column B to subtract off for each panel that I have.

For instance,

51	.	31
50	.	30
47	20	27
51	.	31
25	.	5
49	.	29
45	.	25
24	.	4
51	.	1
22	.	-28
27	.	-23
57	.	7
20	.	-30
57	50	7
59	.	9
33	.	-17

Would this be possible?

Many thanks,
Lisa
*
*   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