Announcement

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

  • varname alias not allowed?

    If I import a dataset with variable "alias" it will not be recognized and gives an error. Furthermore I cannot create a variable named "alias". Is this a bug or intentionally related to fralias? I'm using Stata 18.
    Last edited by Dave Airey; 01 Jun 2023, 08:34.

  • #2
    Are you sure? Could it be someething else? In Stata 18 I get:

    [CODE]
    . gen alias=1
    . list
    +-------+
    | alias |
    |-------|
    1. | 1 |
    +-------+
    [ /CODE]

    Perhaps you could post some details.
    I am aware that data types (int, float, etc) are reserved, but I am not aware of any "official" list of reserved words.

    Comment


    • #3
      It seems that -alias- has become a protected name in Stata 18 very likely due to the new frame alias feature? I think this may qualify as a bug because -alias- is not listed in the reserved word list for variable names (-help naming conventions-).

      If you try to create the variable directly then you get the following error. I wonder if Stata treats alias a type behind the scenes.

      Code:
      . gen alias = .
      type alias not allowed
      Edit: crossed with #2. It seems that Daniel and I arrived at conflicting results. I'm using Stata 18 (15may2023) for Windows.
      Last edited by Leonardo Guizzetti; 01 Jun 2023, 08:58.

      Comment


      • #4
        Weird. Thanks both. I'd say this is a bug. I'll send a note to tech support.

        Comment


        • #5
          alias indeed is a (possible) variable type in Stata 18

          Code:
          help dta_120##variabletypes

          Comment


          • #6
            Thank you for highlighting this Daniel. I would still think this is a bug (and perhaps a need to update documentation for the reserved words list).

            If -alias- were not intended to be a reserved word, then explicitly setting the variable type should resolve the problem, but it does not. Indeed, all variable types are included as part of the reserved words list.

            Comment


            • #7
              Originally posted by Leonardo Guizzetti View Post
              I would still think this is a bug
              I am not sure whether I would call it a bug; anyway, the rules for alias seem to be different than those for the other data types. This is most apparent in Mata:

              Code:
              . clear
              
              . mata : (void) st_addvar("byte", "alias")
              
              . describe
              
              Contains data
               Observations:             0                  
                  Variables:             1                  
              ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
              Variable      Storage   Display    Value
                  name         type    format    label      Variable label
              ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
              alias           byte    %8.0g                 
              ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
              Sorted by: 
                   Note: Dataset has changed since last saved.
              
              . mata : (void) st_addvar("byte", "int")
              int invalid varname
              r(198);

              Comment


              • #8
                According to the response from tech support, alias is now a reserved word in Stata version 18 and the documentation will be updated.

                Comment


                • #9
                  Thanks for reporting back on the issue. I was uncomfortable with that inconsistency.

                  Comment

                  Working...
                  X