title: SPSS compute new variables with if statements if same field with multiple IDs in same field
body: <p>I need to compute a new variable in SPSS that reads "1" if an ID has a score in the "Fall" and in the "Spring". Below is an examples of the data. I would like the output for ID #14576=0 since it only has ratings for the Spring, but ID #10869=1 since it has ratings in the spring and the fall. The timePeriod variable is in "string" format so I tried the formula below but it just provides "0" next to all the IDs. Do you know what I should do?</p>
  
  <pre><code>compute bothtimeperiods=0.
  if (timeperiod="Fall" and timeperiod="Spring") bothtimeperiods=1.
  </code></pre>
  
  <p>The data is:</p>
  
  <pre><code>ID      rating  timePeriod
  14576   3.0     Spring
  14576   2.0     Spring
  14576   5.0     Spring
  14576   4.0     Spring
  10869   1.0     Spring
  10869   2.0     Spring
  10869   4.0     Spring
  10869   4.0     Spring
  10869   1.0     Fall
  10869   5.0     Fall
  10869   5.0     Fall
  10869   2.0     Fall
  </code></pre>