Question

I am trying to find an efficient way for converting yes/no to 1/0 in Excel. Since I am doing the data analyzing at SPSS. Or if there is a way converting YES/NO to 1/0 in SPSS directly?

Was it helpful?

Solution

Try this syntax in SPSS:

This will create a new field with 1 and 0. Also keep in mind that it's case sensitive.

numeric boolFieldName(f1).

recode ynFieldName ("YES" = 1) ("NO" = 0) into boolFieldName.
execute.

OTHER TIPS

If a cell contains yes or no (say cell A1) then in another cell enter:

=IF(A1="yes",1,0)

Add the below formula in the "Format, Custom". This will replace a 1 with "Yes" and 0 with "No"

"Yes"_)_%;"ERROR"_)_%;"No"_)_%;"ERROR"_)_%

In Excel just use Ctr-H (find and replace). Search for Yes replace all with 1 and opposite for No. Simple :)

Normally SPSS automatically converts Excel date/time values into SPSS data values. The number you report is the raw Excel date value, i.e., it was not converted. This is most likely due to the column containing some values that are not dates or times, so SPSS treats it as a plain numeric field. Look at the problematic column to see if you can spot such entries.

=--(A1="yes"), this will return 1 if yes, otherwise, it will return 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top