Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SAS如果有其他多个条件_Sas - Fatal编程技术网

SAS如果有其他多个条件

SAS如果有其他多个条件,sas,Sas,提示是如果患者有三种症状(头痛、恶心和疲劳),则疾病=1。机器发出红旗“语句无效或使用顺序不正确”。非常感谢 这是一个语法错误。应该是: if (symptom = 'headache' and symptom = 'nausea' and symptom = 'fatigue') then disease = 1; else disease = 0; format disease diseasef.; proc freq data = xls_sas; title 'Freque

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

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

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;

您可能需要学习SAS的基本语法:

您有一个逻辑错误。对于任何给定的观察,可变症状只能包含一个值。因此,它的价值不可能同时是头痛和恶心。您是否正在尝试跨多个观察点进行测试?或者可能在一次观测中跨越多个变量?一个变量只包含一个值,所以它不能同时是三个不同的值(欢呼上帝和上帝)。(傻笑/露齿而笑)也可能只是编码
disease=0是的,@Richard。我有多粗心_
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;
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;