Announcement

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

  • Basic learning - create syntax

    Hi, I am currently learning to use stata and for this I use the sysuse auto file.

    I wanted to use the command "list" which only shows the variable foreign if the varibale is "Domestic" or on the other hand "Foreign".
    I tried to create this:

    list foreign if foreign==Foreign

    or

    list foreign if foreign==Domestic

    Both times, I get an error message:
    r(111);

    What would be the corrent syntax?

    Thanks for your support.

  • #2
    it depends on whether the variable is numeric with value labels or is string - what you did will not work for either; let's imagine that the variable is string - then you need double quotes around the work following the double equals sign; if the variable is numeric with value labels and the label is called, say, "country" then you could try
    Code:
    list foreign if foreign=="Foreign":country
    and the above should serve as a good example re: why the FAQ calls for giving data examples using -dataex- and posting within code blocks - please read and follow the advice in the FAQ

    note that the error message you received may well point to a different problem such as the lack of a variable called "foreign" in your data set; see
    Code:
    h r(111)

    Comment

    Working...
    X