SAS如果存在多种情况


if (symptom = 'headache' and symptom = 'nausea' and symptom = 'fatigue') then disease = 1;
else disease = 0;
format disease diseasef.;

proc freq data = xls_sas;
title 'Frequency Tabulation Disease X';
tables disease;
run;

提示是,如果患者有三种症状(头痛、恶心和疲劳(,则疾病=1。机器升起红旗";语句无效或使用顺序不正确";。非常感谢!

proc sort data=xls_sas nodupkey;
by patient symptom;
run;
data xls_sas(drop=symptom);
set xls_sas;
by patient;
format disease diseasef.;
retain flag 0;

if first.patient then flag=0;

if symptom in ('headache', 'nausea', 'fatigue') then flag+1;
if flag=3 then disease=1;
else disease=0;

if last.patient;
run;

这是一个语法错误。应该是:

data xls_sas;
set xls_sas;
if (symptom = 'headache' and symptom = 'nausea' and symptom = 'fatigue') then disease = 1;
else disease = 0;
format disease diseasef.;
run;

您可能需要学习SAS的基本语法:https://www.sas.com/storefront/aux/en/splsb/73044_excerpt.pdf

最新更新