Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata doesn't save properly?

    Unfortunately I cannot provide a MWE due to the confidentiality and size of the data. But here is a copy-paste of my console of what is happening. Essentially I'm appending several files together and everything is fine. Then I save the combined files into a new file and upon reloading the same file some entries have simply been changed. I can't make sense of this. Can somebody explain?

    Code:
    . do "/tmp/SD162064.000000"
    
    .     * Combine years (2008-2017, 2016 not given)
    .     use              "$pathEst/input/cleaning_intermediate/F101_2008_data.dta", clear
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2009_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2010_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2011_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2012_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2013_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2014_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2015_data.dta"
    
    .     qui append using "$pathEst/input/cleaning_intermediate/F101_2017_data.dta"
    
    .    
    .     * Store intermediate file
    .     save $pathEst/input/cleaning_intermediate/F101_data_all_years.dta, replace
    file
        ~/data/transactions_ecuador/3_mivazq/Masters_Thesis/estimation/input/cleaning_intermedi
        > ate/F101_data_all_years.dta saved
    
    .
    end of do-file
    
    . tab year
    
    ANIO_FISCAL |      Freq.     Percent        Cum.
    ------------+-----------------------------------
           2008 |    122,408       11.20       11.20
           2009 |    128,116       11.73       22.93
           2010 |    122,497       11.21       34.15
           2011 |    105,965        9.70       43.85
           2012 |    118,403       10.84       54.68
           2013 |    121,721       11.14       65.83
           2014 |    128,361       11.75       77.58
           2015 |    117,485       10.75       88.33
           2017 |    127,488       11.67      100.00
    ------------+-----------------------------------
          Total |  1,092,444      100.00
    
    . clear all
    
    . use "$pathEst/input/cleaning_intermediate/F101_data_all_years.dta", clear
    
    . tab year
    
    ANIO_FISCAL |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              0 |        970        0.09        0.09
           2008 |    122,408       11.20       11.29
           2009 |    128,116       11.73       23.02
           2010 |    122,497       11.21       34.23
           2011 |    105,430        9.65       43.89
           2012 |    118,403       10.84       54.72
           2013 |    121,721       11.14       65.87
           2014 |    128,361       11.75       77.62
           2015 |    117,485       10.75       88.37
           2017 |    127,053       11.63      100.00
    ------------+-----------------------------------
          Total |  1,092,444      100.00
    
    .
    Btw. not only "year" variable has been set to zero. ALL variables are set to zero for those 970 entries.


    Interestingly, if I perform

    Code:
    cf _all using "$pathEst/input/cleaning_intermediate/F101_data_all_years.dta"
    after opening the file, then it doesn't return anything (implying the dataset loaded is identical to the one stored). But this is funny because I tabulated "year" AFTER saving it, and there were no zero entries...


    Thanks a lot!

    EDIT: I'm using Stata 18.0 MP—Parallel Edition (4 core)
    Last edited by Miguel Vazquez; 03 Dec 2023, 08:03.

  • #2
    If you have a legal copy of Stata, contact Technical Services as Stata is not supposed to change observations in saved datasets. See https://www.stata.com/support/tech-support/contact/ on how to do so.

    Comment

    Working...
    X