Announcement

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

  • Drop original after rename

    I made a simple rename then to create a 'messy' recode used capture drop. This drops my rename variable as below. What did I do wrong?

    tab e4_1 // there
    rename e4_1 e4_1Orig
    rename e4_2 e4_2Orig
    su e4_?Orig // both there
    su e4_? // not there
    capture drop e4_1 // drops e4_1Orig ??

    Stata13.1 for windows (64 bit) Revision 31 March

    Regards
    Laurence
    Last edited by Laurence Lester; 11 Apr 2014, 00:31.

  • #2
    This is why I choose to set varabbrev off

    Comment


    • #3
      Add new line in profile.do! One day it will be a bug and not me -- then I may retire, Thanks.
      Last edited by Laurence Lester; 11 Apr 2014, 00:41.

      Comment


      • #4
        Alternatively you can set varabbrev off, permanently

        Comment


        • #5
          Thanks.

          Comment


          • #6
            This may be a silly question, but why would you want to drop e4_1 when it's no longer there? That's the reason why Stata "thinks" you want to get rid of e4_1Orig

            Consider the following
            Code:
            sysuse auto, clear
            g make_1 = make
            g make_1Orig = make
            drop make_1
            This gets rid of make_1 and keeps make_1Orig, so the problem is that in your drop command you are telling it to drop a variable that is no longer there. Shouldn't you already know that the variable is not there and thus not use it? I say this because I believe that if you use the drop command the way you did it should be because you know that at the point where the variable name you're using is no longer relating to a variable, it will be taken as an abbreviation, and thus it is a nice feature to have. Although, truth to be said I always use the wildcard * when I want to get rid of all the variables with a common trunk in the name. But in all cases I am always pretty aware of what variables I still have in the sample and which I don't, which is why I don't understand how what you mention could ever be a problem. Please satisfy my curiosity if you don't mind.
            Alfonso Sanchez-Penalver

            Comment


            • #7
              Sorry for the delay -- away from internet.

              The example I gave was a simple cut down (incomplete) version. The 'capture drop...' preceded the recoding of the new version e4_1 (or _2) of the original (now e4_1_Orig) with the messy recoding etc (I needed to be able to run through a few times until I got what I wanted).
              For what it’s worth this is the next t lines:
              gen e4_1 = .
              replace e4_1 = e4_1_Orig-1 if e4_1 !=.m & e4_1 !=.u

              probably not the most elegant but...
              Regards
              Laurence

              Comment

              Working...
              X