Announcement

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

  • Drop if - variable not found

    Hi all,

    Just a very simple question and command yet I can't figure out why it is not working.

    I just downloaded a dataset on all company's in the North-American market. Now I simply want to get rid of the American companies to see whether all cross-listed companies have a foreign primary issue tag. Therefore, as a first command (after clear all, cd and sysuse) I run:
    drop if fic==USA
    And then it says:
    USA not found

    It does not work for any of the -fic- or -tic- commands, but if I for instance do the command:
    drop if fyear==2002
    Then it does drop the years 2002

    How is this possible and how can I resolve this? Thanks in advance for your help.

  • #2
    Code:
    drop if fic == "USA"
    Otherwise Stata is looking for a variable named USA, which you do not have. That's what Stata is telling you.

    Comment


    • #3
      I thought I already tried all of these, but I only tried either with apostrophes or with spaces, not combined. Thank you Nick!
      Good to know that without spaces and brackets it reads it as a variable - this does explain why it did drop the whole variable fic if I typed it in the same format.

      Comment


      • #4
        The difference is in the quotation marks only.
        Compare:
        Code:
        webuse grunfeld, clear
        tostring company, replace
        drop if company=="2"
        Drops obs where company has the value "2"

        Code:
        webuse grunfeld, clear
        drop if company==time
        Drops obs where the variable company has the same value as the variable time

        Comment


        • #5
          Yes I just noticed it. instead of " I used ' so that was the mistake I made. Thanks again.

          Comment

          Working...
          X