Announcement

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

  • Error r(198) variable with invalid name

    Dear all,

    I have a problem with a variable in a dataset that begins with È_ .
    It's not possible to change, to rename or to drop it neither export the dataset.
    There is some way to use it or to change it?

    Best Regards and thank you for your attention

  • #2
    Ottavia:
    I cannot replicate your problem.
    Anyway, you may want to try:
    Code:
    . set obs 10
    number of observations (_N) was 0, now 10
    
    . g È_=runiform()
    
    . clonevar A=È_
    
    . drop È_
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,


      if I replicate your example Stata says to me after generate:

      g È_=runiform()

      È_ invalid name

      r(198);

      How is it possible?

      Best Regards,
      Ottavia

      Comment


      • #4
        What version of Stata are you using? As explained in the FAQ, you are asked to state use of any version of Stata other than the latest, 14.1 as I write.

        It may just be easiest to push your dataset out of Stata, using an export command, fix the variable names in a text editor or spreadsheet as congenial and then pull in it back again.

        Comment


        • #5
          Ottavia:
          two wild guess/questions:
          - which Stata release are you using ? (as you surely know, posters are assumed to use the last available Stata release, otherwise they should communicate which Stata release they're referring to);
          - if you're using Stata 14, is it fully updated?

          PS: cyber-crossed with Nick's reply.
          Last edited by Carlo Lazzaro; 20 Apr 2016, 04:00.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Dear Nick and dear Carlo,

            sorry for my lack, well I'm using Stata 12 SE.

            Not even with the export command I've solve the problem.

            Thanks again for your patience and your help!

            Comment


            • #7
              Perhaps a quick fix if it is just one variable: have you tried changing the name whilst in the data editor?
              Click image for larger version

Name:	1.png
Views:	1
Size:	52.5 KB
ID:	1336607

              Comment


              • #8
                Dear Jorrit,

                not even with your method.



                Comment


                • #9
                  You don't say exactly what you tried with export. You will have to edit the names outside Stata. I don't believe that to be impossible.
                  Last edited by Nick Cox; 20 Apr 2016, 05:05.

                  Comment


                  • #10
                    Ottavia:
                    eventually I have replicated your problem in Stata 12.
                    Code:
                    . set obs 1
                    obs was 0, now 1
                    . g È_=runiform()
                    È_ invalid name
                    r(198);
                    As Nick said, your problem should be fixed outside Stata.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      I'm actually also quite curious as to how the variable name got there in the first place. In Stata 13.1 I cannot create a variable È, nor import it from an xls, nor can i open Stata 14 files.

                      Comment


                      • #12
                        Thanks to everybody for your support.

                        I was able to export the dataset only as txt file, because as xls or xlxs file was not possible.

                        Following the suggestion of Nick and Carlo, I'll change the name of variable outside Stata.

                        Many thanks again!

                        P.S. For Jorrit I've received this dataset already in Stata version.

                        Comment


                        • #13
                          P.S. For Jorrit I've received this dataset already in Stata version.
                          Aha. If that's the case than it appears saveold does not take into account older versions cannot deal with the new unicode characters in Stata14. That is actually not too silly; it might be somewhat obvious to replace È with E, but it is more difficult to come up with a set of rules for all new characters, e.g., all the new languages (Chinese, Japanese etc) that are allowed. Still, good to know if for people dealing with such datasets and who would want to share across versions.

                          Comment


                          • #14
                            Originally posted by Ottavia Ferraro View Post
                            I've received this dataset already in Stata version.
                            I wonder how your dataset was created. Stata 14 does not allow saveold with a variable name that starts with È_.
                            Code:
                            . set obs 10
                            . g È_=runiform()
                            . clonevar A=È_
                            . saveold test.dta
                            (saving in Stata 13 format)
                            (FYI, saveold has options version(12) and version(11) that write files in older Stata formats)
                            variable name "È_" does not meet the restrictions of old .dta format.  Probably it does not
                                start with an ASCII character.
                            r(459);
                            This shows that what Jorrit wrote is not true.

                            Originally posted by Jorrit Gosens View Post
                            If that's the case than it appears saveold does not take into account older versions cannot deal with the new unicode characters in Stata14.

                            Comment


                            • #15
                              Well, it's still very true that it appeared that way. Was the only other way I could imagine. The fact that the character is in there suggest it was created with v14, the fact that Ottavia can open it suggested it was saveold and sent to him.
                              Good to know, but then the question remains how that character ended up in this dataset.

                              Comment

                              Working...
                              X