Creating a derived variable using complex logic

Creating a derived variable using complex logic

by Rucha -
Number of replies: 1

Part 3c

Q. 26 would the correct syntax be as follows:

gen disagree = 0

replace disagree=1 if official==1 & opinion==1

replace disagree= . if official==9

replace disagree= . if opinion==9

??

In reply to Rucha

Re: Creating a derived variable using complex logic

by Bardia -

I guess I can't post the answers here; but yours is not correct. Just read the instructions again. Your second command for example " replace disagree=1 if official==1 & opinion==1"; is the oppositeĀ  of what you are trying to do: it makes the "disagree" variable, presentĀ  while both "official" and "opinion" are 1 (i.e. they actually agree when both their values are "1").