Announcement

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

  • generating variable with condition of other variable

    Hi,

    I am trying to use the value of one variable as input into devising another variable and wish to know if it is possible. For example, I have var with a value of "siccode>1239 & siccode<1400" and I wish to create a variable oil=1 if var. In other words, my goal is to create the variable oil=1 if siccode>1239 & siccode<1400. However, I am getting a type mismatch error if attempting to do this as written.

  • #2
    The best way to diagnose your problem is to see a sample of your data, exactly what you typed in Stata, and what Stata returned. Pay special attention to section 12 of the FAQ: https://www.statalist.org/forums/help#stata
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      In addition to Carole's helpful advise on posting questions, it is likely that siccode is a string. (issue ds at the command line to see) If so, you must change it into an integer to do this kind of comparison.

      Comment

      Working...
      X