嵌套ifasser语句
idnat
idnat
idbp
idnat
idbp
idnat2
:
idnat idbp idnat21 french mainland mainland2 french colony overseas3 french overseas overseas4 foreign foreign foreign
if idnat = "french" then do; if idbp in ("overseas","colony") then idnat2 = "overseas"; else idnat2 = "mainland";end;else idnat2 = "foreigner";run;
if(idnat=="french"){ idnat2 <- "mainland"} else if(idbp=="overseas"|idbp=="colony"){ idnat2 <- "overseas"} else { idnat2 <- "foreigner"}
Warning message:In if (idnat=="french") { : the condition has length > 1 and only the first element will be used
ifelse
idnat2 <- ifelse (idnat=="french", "mainland", ifelse (idbp=="overseas"|idbp=="colony", "overseas") ) else (idnat2 <- "foreigner")
胡说叔叔
慕运维8079593