Announcement

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

  • Error message " variable x1 not found" r(111)

    Hi.

    Stata tells me this error code: " variable x1 not found" r(111) after using this command:
    label var x1 "Something Something"

    What can cause this problem? I can't label around 70 out 84 variables because of this problem. I would imagine that this is a pretty basic command, which should not be rocket science.

    Thanks in advance.

  • #2
    Show us your variable names by showing the results of
    Code:
    ds
    The best guess on your information is a problem of upper and lower case.

    Comment


    • #3
      This may also be related to your varabbrev settings.
      Code:
      . sysuse auto
      . set varabbrev on
      . lab var p "Test"
      . set varabbrev off
      . lab var p "Test"
      variable p not found
      r(111);

      Comment


      • #4
        Here you go Nick:

        Code:
         ds
        V000  V006  V012  V018  V024  V030  V036  V042  V048  V054  V060  V066  V072  V078  V084
        V001  V007  V013  V019  V025  V031  V037  V043  V049  V055  V061  V067  V073  V079
        V002  V008  V014  V020  V026  V032  V038  V044  V050  V056  V062  V068  V074  V080
        V003  V009  V015  V021  V027  V033  V039  V045  V051  V057  V063  V069  V075  V081
        V004  V010  V016  V022  V028  V034  V040  V046  V052  V058  V064  V070  V076  V082
        V005  V011  V017  V023  V029  V035  V041  V047  V053  V059  V065  V071  V077  V083
        I tried to use the commands you provided as well Friedrich. Unfortunately, that did not seem to work:
        Code:
        . set varabbrev on
        
        . do "/var/folders/fv/94h9z2s9217bck1bmqwb3ttr0000gn/T//SD00549.000000"
        
        . label var V000 "Individ"
        
        . label var V001 "Intervjurunde"
        
        . label var V002 "År"
        
        . label var V003 "Gang med i AKU"
        
        . label var V004 "Kvartal"
        
        . label var V005 "Direkte eller indirekte intervju"
        variable V005  not found
        r(111);

        Comment


        • #5
          There seems to be something wrong with the do-file. When I type in the label commands manually I manage to label them. However, I have numerous variables and datasets I need to this on.

          Code:
          . label var V005 "Direkte eller indirekte intevju" 
          
          . des V005
          
                        storage   display    value
          variable name   type    format     label      variable label
          ------------------------------------------------------------------------------------------------
          V005            double  %12.0g     V0058      Direkte eller indirekte intevju

          Comment


          • #6
            Fredrik:
            pretty trivial remark indeed, but: are you sure that an upper-case o wasn't mistyped vs 0?
            Last edited by Carlo Lazzaro; 07 Sep 2017, 01:16.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Carlo:
              Luckily for my self esteem, there are no upper-case o's. I notice that Statforum is not cathing up the / in the number 0, like stata does. Thus, If I run this do-file in Windows, I get all of the commands through even though Stata is not finding most of the variables and I manage to type them in manually. I have run the do-file on both Windows and IOS, so there should not be anything wrong with the hardware.

              Comment


              • #8
                This runs fine for me as a do file:

                Code:
                clear all
                set obs 100
                corr2data V000 V001 V002 V003 V004 V005
                
                label var V000 "Individ"
                label var V001 "Intervjurunde"
                label var V002 "År"
                label var V003 "Gang med i AKU"
                label var V004 "Kvartal"
                label var V005 "Direkte eller indirekte intervju"
                
                des
                Does it run for you?

                I would check to make sure my version of Stata was up to date. Also, in your do file, delete or retype the problem line. Maybe there is some weird invisible character causing you grief.
                -------------------------------------------
                Richard Williams, Notre Dame Dept of Sociology
                StataNow Version: 19.5 MP (2 processor)

                EMAIL: [email protected]
                WWW: https://www3.nd.edu/~rwilliam

                Comment


                • #9
                  Code:
                  . label var V005 "Direkte eller indirekte intervju"
                  variable V005  not found
                  r(111);
                  Did you copy and paste the output exactly as it appears in the Stata Results window? Why is there an extra space between "variable V005" and "not found"?

                  Could you share an excerpt from your dataset with dataex (see section 12.2 in the FAQ) that includes some variables that cause and do not cause problems, e.g. V004 and V005?

                  Comment


                  • #10
                    Yes, that worked out fine for me too.

                    However, I retyped the command exactly how it was and it worked. Due to a lot of variables, I did some formating in Excel with the labels, which made a kind of space between V005 and "Direkte..", but not the same space as you do with " space " on your keyboard. I have attached a screenshot to show the difference. Note the tiny dots and where they are missing:
                    Click image for larger version

Name:	Skjermbilde 2017-09-07 kl. 10.29.09.png
Views:	1
Size:	128.8 KB
ID:	1409523


                    Thanks for all the helpful advices.

                    Comment


                    • #11
                      It should not be necessary to use Excel. Do you still have the original data? If you tell us what did you did in Excel with the variable names we can suggest how to do the same in Stata.

                      Comment

                      Working...
                      X