# [Solved] Converting Numerical Values to Binomial

Member Posts: 18 Contributor I
edited November 2018 in Help
Hi

Very new user here so apologies if this questions seems dumb!!

I have some survey data with answers to each question as follows:

Yes = 1
No = 2
Undecided = 3
etc

I want to remove all values not equal to 1 or 2 or set it to "N/A" and then set values = 1 to "True" and set values = 2 to "False"

I presume there is a much better way to do this?? Or is this way as simple as any??

Any help appreciated :-)

Thanks

Neil

• Member Posts: 18 Contributor I
One other thing - I can't remove the rows containing the values 3 or 4 as these occur on different lines each time.
• Administrator, Moderator, Employee, Member, University Professor Posts: 1,985 RM Engineering
Hi,

does each row only contain the answer to a single question? Is the anwer column nominal? f so, you can use the Filter Examples operator to get ride of rows where the value is not 1 or 2. Then you can use Generate Attributes (on the very same answer column, the operator can overwrite existing values) with this expression:
`if (Answer=="1", "true", "false")`
otherwise you can do
`if (Answer=="1", "true", if (Answer=="0", "false", NaN))`
Regards,
Marco
• Member Posts: 18 Contributor I
Hi

• Member Posts: 18 Contributor I
Thanks Marco, that second piece of code did the trick 