Announcement

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

  • Cap drop using a wildcard?

    Hi guys, does anyone notice that the "cap drop" command may use something like wildcard? i.e. "cap drop y" might drop variables starting with "y" (e.g. "yr").
    It's alright when you run it as a single command. But once you use it in a do file, the wildcard effect appears.

    Click image for larger version

Name:	Screenshot 2020-09-21 173735.jpg
Views:	1
Size:	43.8 KB
ID:	1573578

  • #2
    I can't imagine why this being in a do-file makes any difference to how it works.

    Also y here isn't a wildcard. It just turns out to be the abbreviation of yr

    Code:
    set varabbrev off 
    is what you may be seeking.

    Comment


    • #3
      This example might illustrate why this is not a wild card:

      Code:
      . sysuse auto, clear
      (1978 Automobile Data)
      
      . keep pr
      
      . gen pretty = price
      
      . keep pr
      pr ambiguous abbreviation
      r(111);
      So in the first case because there was only one variable starting with pr (price) Stata took the abbreviation and executed the command.

      In the second case, because there are two variables starting with pr, Stata exists with an error message. So this is not a wild card situation.

      Comment

      Working...
      X