Announcement

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

  • Generating new variable - Qualtrics export

    I am generating a new variable based on existing variables in my dataset which were exported from Qualtrics. Using the following code:

    gen X = .
    replace X = 1 if Y == 1

    The result is showing 0 changes made however there should be 64 changes. I've never come across this problem before, I wonder if it has something to do with the type of variable. Y (exported from Qualtrics) is double and X (that I generated) is a float.

    replace X = 1 if Y== 1
    (0 real changes made)

    It only seems to be this one variable, all new variables have work. Anyone come across this before?


  • #2
    I have solved this problem.

    Gen X=Y Then Replace X=. If Y! =1

    Comment


    • #3
      You can abbreviate those two statements into:

      Code:
      gen x = y if y != 1

      Comment

      Working...
      X