Announcement

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

  • Meaning of different characters

    gen intra_nafta = (ccode=="CAN" | ccode=="MEX" | ccode=="USA") & (pcode=="CAN" | pcode=="MEX" | pcode=="USA")
    replace intra_nafta = 0 if year < 1994
    label var intra_nafta "1 if trade bewteen nafta members"
    gen imp_nafta_rest = (ccode=="CAN" | ccode=="MEX" | ccode=="USA") & (pcode!="CAN" & pcode!="MEX" & pcode!="USA")

    I don't understand the difference between the two commands in bold and the usage of "!", "|" and "*".

  • #2
    Kendal:
    welcome to this forum.
    See -help operator-.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      This rewriting

      1. shortens the code

      2. may help explain what it does

      3. corrects a minor typo

      Code:
      gen intra_nafta = inlist(ccode, "CAN", "MEX", "USA") & inlist(pcode, "CAN", "MEX", "USA")
      replace intra_nafta = 0 if year < 1994
      label var intra_nafta "1 if trade between nafta members from 1994" 
      
      gen imp_nafta_rest = inlist(ccode, "CAN", "MEX", "USA") & !inlist(pcode, "CAN", "MEX", "USA")

      Comment


      • #4
        OK, thank you! I'm new to STATA, and I have a lot to learn.
        Originally posted by Nick Cox View Post
        This rewriting

        1. shortens the code

        2. may help explain what it does

        3. corrects a minor typo

        Code:
        gen intra_nafta = inlist(ccode, "CAN", "MEX", "USA") & inlist(pcode, "CAN", "MEX", "USA")
        replace intra_nafta = 0 if year < 1994
        label var intra_nafta "1 if trade between nafta members from 1994"
        
        gen imp_nafta_rest = inlist(ccode, "CAN", "MEX", "USA") & !inlist(pcode, "CAN", "MEX", "USA")

        Comment

        Working...
        X