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]

From |
"Gokhan Yilmaz" <yilmag@rpi.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: Replacing the missing observations |

Date |
Thu, 17 Nov 2011 18:06:18 -0500 |

Thanks Dr. Cox, I ran the command as you suggested and read the FAQ. However, I could not figure out why it worked for only some of the time values. It replaced a zero for the ewdiffret instead of the actual values in 2007m6 through 2007m12 and 2008m2. I had tsset the data but I also tried it after "tsset, clear" and the same thing happened. For the other time values it worked perfectly. Also it may seem like I am trying to replace for only one observation in a given month but indeed there are around 345 observations for each month to be replace with the same ewdiffret value in that given month. group time ewportret ewdiffret 0 2007m4 .041679 1 2007m4 .0375245 -.0041545 0 2007m5 .0449738 1 2007m5 .0397919 -.0051819 0 2007m6 -.0240277 1 2007m6 -.0188678 .0051599 0 2007m7 -.064496 1 2007m7 -.0456775 .0188185 0 2007m8 .0023347 1 2007m8 .0104131 .0080783 0 2007m9 .0237398 1 2007m9 .0209782 -.0027617 0 2007m10 -.0086541 1 2007m10 .0190929 .0277471 0 2007m11 -.0589931 1 2007m11 -.0399782 .0190149 0 2007m12 -.0302353 1 2007m12 -.0077903 .022445 0 2008m1 -.0117908 1 2008m1 -.0418619 -.0300711 0 2008m2 -.0362031 1 2008m2 -.0311441 .0050591 0 2008m3 .0164306 1 2008m3 -.0015971 -.0180278 Regards, Gokhan -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Wednesday, November 16, 2011 5:24 AM To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: Replacing the missing observations This is an FAQ. FAQ . . . . . . . . . . . . . . . . . . . . . . . Replacing missing values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox 9/05 How can I replace missing values with previous or following nonmissing values or within sequences? http://www.stata.com/support/faqs/data/missing.html In this example bysort time (ewdiffret) : replace ewdiffret = ewdiffret[1] Note that -replace- is a command (not a function). would work. Nick n.j.cox@durham.ac.uk yilmag@rpi.edu group time ewportret ewdiffret 0 2007m4 .041679 . 1 2007m4 .0375245 -.0041545 0 2007m5 .0449738 . 1 2007m5 .0397919 -.0051819 0 2007m6 -.0240277 . 1 2007m6 -.0188678 .0051599 The variable ewdiffret is the difference in ewportret between group 1 and group 0 for each time variable (thanks to Dr. Cox for the help with this). My question is how can i now replace all empty cells under the ewdiffret in the same month with the single ewdiffret value in that given month. Indeed i have too many empty cells in a given month and i want to replace them all with the single ewdiffret i have for that month. For example: I would like to have the first empty cell under ewdiffret equal to -.0041545 as the time variable for both is 2007m4 and the second empty cell equal to -.0051819 as their time variable is 2007m5. Using too many replace functions takes a long time and may cause transcription errors. * * 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/ * * 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/

**Follow-Ups**:**Re: st: RE: RE: Replacing the missing observations***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: Replacing the missing observations***From:*yilmag@rpi.edu

**st: RE: Replacing the missing observations***From:*Nick Cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: When to use stdize and stdweight with svy: tab and svy: mean?** - Next by Date:
**Re: st: Average when -inrange()-** - Previous by thread:
**st: RE: Replacing the missing observations** - Next by thread:
**Re: st: RE: RE: Replacing the missing observations** - Index(es):