Sample Header Ad - 728x90

Replace Yes with 1 and No with 0

1 vote
1 answer
8104 views
I have a data set and an example of the field is below. The values of these fields is "Yes" or "No". I would like to replace the value of "Yes" with 1 and the value of "No" with 0. This file will be exported from Sharepoint each month and at the moment it is 50,000 rows and will increase each month. I have 48 fields which I would like to do the replace of "Yes" and "No". ### Example of the field t1.'Domestic Violence'n, I'm using the below to accomplish what I'd like, but was hoping there is a better way to do this. Ideally, I don't want to create another column. I am using SAS . For example: t1.'Domestic Violence'n as DomesticViolence, case when(DomesticViolence='Yes') then 1 else 0 end as Domestic_Violence, I would like a more efficient way (less coding). With the above I'll have a column called 'DomesticViolence' (values of "Yes" and "No") and a column called 'Domestic_Violence'. Ideally I'd only want the column called 'Domestic_Violence'.
Asked by Haydn Rotumah (11 rep)
Jul 15, 2015, 02:55 AM
Last activity: Oct 31, 2018, 12:16 PM