Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Tracking Replacements Made to Variables


From   Christopher Lanoue <[email protected]>
To   [email protected]
Subject   st: Tracking Replacements Made to Variables
Date   Mon, 31 Jan 2011 16:13:26 -0500

Hi,
My problem is that I am trying to keep track of changes that I make to
my data using STATA. For instance if I have data such as:

yr        var1
1961    15
1962     .
1963    20
1964     .
1965    30

and I want to take the average of the two data points to fill in the
missing values.

I run replace var1 = (var1[_n-1]+var1[_n+1])/2 if var1 == . to
accomplish this task, but STATA simply outputs (2 changes made) to the
display. Is there any way to capture the changes STATA makes, i.e.
loop through the changes (if the changes are saved somewhere) and
output something like "var 1, year 1962. Average of 1961 and 1963."?
If this is not possible, is there are a way to use subscripts on the
variable so that I can loop through each value and if a change is
made, output the string above, i.e. replace var1[`i'] = .... and then
display "var 1, yr[`i']. Average of yr[`i'-1] and yr[`i']+1."
Any help would be greatly appreciated.
Thanks in advance,
Chris
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index