0
votes
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;

The prompt is if the patient has three symptoms (headache, nausea and fatigue), then disease = 1. The machine raises red flag "Statement is not valid or it is used out of proper order". Many thanks!

2
You have a logic error. The variable SYMPTOM can only contain one value for any given observation. So it is impossible that the value is both headache and nausea at the same time. Are you trying to test across multiple observations? Or perhaps across multiple variables on a single observation?Tom

2 Answers

0
votes
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;
-2
votes

It's a syntax error. It should be:

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;

You may need to learn basic syntax of SAS: https://www.sas.com/storefront/aux/en/splsb/73044_excerpt.pdf