I'd like to create a dummy variable from a string variable (Q1) with different comments in it with syntax. If Q1 is empty paste a zero into Q1_d and if Q1 has text inside it paste one into Q1_d.
Asked
Active
Viewed 282 times
1 Answers
2
COMPUTE Q1_d=LENGTH(Q1)>0.
Which will create dichotomous 0/1 variable Q1_d. If row case data at Q1 has data/characters then a 1 (one) will be assigned at Q1_d else if Q1 equals an empty string then 0 (zero) will be assigned.

Jignesh Sutar
- 2,909
- 10
- 13