Hi,
I have no idea of R-programming, I want to understand this script in SAS. Could you help me out.
#--------------------------------------------------------------------------#
dt3 <- dt2 %>%
mutate(Race_Ethnicity = case_when(
FirstRace %in% c('American Indian/Black', 'Black', 'Black/White') ~ 'Black'
,Ethnicity == 'Hispanic or Latino' & !(FirstRace %in% c('American Indian/Black', 'Black', 'Black/White')) ~ 'HispanicLatino'
,FirstRace %in% c('White', 'Middle Eastern') & Ethnicity != 'Hispanic or Latino' ~ 'White'
,FirstRace %in% c("Asian", "Oriental", "American Indian/Asian", "Asian/White", "American Indian/White") & Ethnicity != 'Hispanic or Latino' ~ "Asian"
,FirstRace %in% c("*Unknown", "American Indian/Alaska Native","Decline", "Do Not Know", "Multi-Racial" ,
"Native Hawaiian/Pacific Islande", "Other", "Z") & Ethnicity != 'Hispanic or Latino' ~ 'Other_Unknown'
,TRUE ~ "Other_Unknown" #some missing value
))
dt3$FirstRace[dt3$FirstRace %in% c("*Unknown", "Do Not Know", "Decline")] <- "Unknown"
thanks