Announcement

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

  • How come label changes aren't registered by Stata

    Hi
    I just discovered that changes in labels is not captured by either c(changed) or describe (In the manual they are said work similarly) as seen by:
    Code:
    cls
    sysuse auto, clear
    label variable rep78 "Change label"
    describe
    display "`c(changed)'"
    
    sysuse auto, clear
    gen x = 1
    label variable rep78 "Change label"
    describe
    display "`c(changed)'"
    Is there a way to detect all changes in a dataset?

    Looking forward to hear from you
    Last edited by Niels Henrik Bruun; 06 Dec 2018, 08:24.
    Kind regards

    nhb

  • #2
    Originally posted by Niels Henrik Bruun View Post
    Is there a way to detect all changes in a dataset?
    I am not aware of anything beyond cf, compare, dta_equal, etc., all of which are concerned with values in variables.

    But then, I find it hard to define what all changes would include. Does this include changes to the order of variables? Does it include changes to variable's display format? Does it include changes to characteristics and notes?

    Best
    Daniel

    Comment


    • #3
      Dear Daniel
      Thank you for your answer.

      Yes, I would have expected changes in order and label to so important that I should be able to detect if such changes has happened.
      And I would have liked to be warned if all my labelling work was about to disappear without warnings when importing another dataset.

      But that is just me.

      Kind regards nhb
      Kind regards

      nhb

      Comment


      • #4
        Niels

        you are not the only one wondering about what exactly is flagged as a change to the dataset in c(changed). A while ago, I was surprised that neither reshaping the dataset nor dropping all variables would be flagged as changes to the dataset. Try

        Code:
        webuse judges
        reshape wide rating , i(target) j(judge)
        display c(changed)
        drop _all
        display c(changed)
        I think that StataCorp should include a technical note in the documentation that clearly describes what constitutes a change to the data in memory and what does not.

        Best
        Daniel

        Comment


        • #5
          Dear Daniel
          I totally agree
          Kind regards

          nhb

          Comment


          • #6
            I believe reshape adds a characteristic to the data set to indicate that reshape was used. That said, if the concern is limited to the domain of a data set on disk, then a version control program could indicate if there were any changes. Displaying the results in a useful way would probably be a bit more changing since the change detection would rely on a binary diff.

            Comment


            • #7
              -xmlsave- still working, but no longer an official part of Stata, may be used to save text files with metadata only to be compared with a diff tool, (or parsed).
              Code:
              sysuse auto
              xmlsave A.xml in 1 if _n < 1 , doctype(dta) legible replace /* dtd */
              lab var make "make mistake"
              xmlsave B.xml in 1 if _n < 1 , doctype(dta) legible replace /* dtd */  
              * then compare A.xml with B.xml using your favorite tool
              Code:
              * Simple use, but not covering value label values and characteristics
              * using possibly a second Stata session
              
              xmluse B.xml , clear
              describe , replace
              save B , replace
              xmluse A.xml , clear
              describe , replace
              cf * using B , all verbose
              Code:
              . cf * using B , all verbose
                      position:  match
                          name:  match
                          type:  match
                     isnumeric:  match
                        format:  match
                        vallab:  match
                        varlab:  1 mismatch
                                 obs  1. Make and Model in master; make mistake in using
              r(9);
              Last edited by Bjarte Aagnes; 21 Dec 2018, 15:11.

              Comment


              • #8
                Dear Bjarte
                Thank you very much for your suggestion. I'll look into it.
                Sorry, that I didn't answer before - Holiday
                Kind regards

                nhb

                Comment

                Working...
                X