I am having a hard time getting through a macro IF-THEN statement. I have the following code that does not seem to be working: %if %str(&protocol.)=%str(EC-FV-04) | %str(&protocol.)=%str(EC-FV-06) %then %do; ... %end; I am getting the error: "A character operand was found in the %EVAL function or %IF condition where a numeric operand is required." I am assuming that the hyphens are telling SAS to do a mathematical subtraction, which it cannot do with characters (nor do I want it to do so). I have tried various ways to run the comparison, but I am not having much luck. As a side note, is it possible to use the "in" operator in a macro? I would like to be able to state: %if %str(&protocol.) in (%str(EC-FV-04),%str(EC-FV-06)) %then %do; ... %end; Here is my full code, if it will help: %macro CTSCHEDULE (protocol=%str(),drugstartdt=); %let drugstartdt=%sysfunc(upcase(&drugstartdt.)); %put &drugstartdt.; data _null_; position=prxmatch("/\d\d[A-Z][A-Z][A-Z]\d{4}/","&drugstartdt."); call symputx('position',position); run; %if %length(&drugstartdt.)^=9 %then %do; %put ERROR: Incorrect Length. DRUGSTARTDT must be in the form DDMMMYYYY.; %return; %end; %if &position.^=1 %then %do; %put ERROR: Incorrect Format. DRUGSTARTDT must be in the form DDMMMYYYY.; %return; %end; data schedule; do CYCLE=1 to 30; do CYCLEWEEK=1 to 4; output; end; end; run; data schedule; set schedule; EVENT='C' || compress(put(cycle,best.)) || 'W' || compress(put(cycleweek,best.)); STUDYWEEK=_n_; CTDT="&drugstartdt."d + (studyweek-1)*7; format ctdt date9.; run; data ctschedule; set schedule; %if %str(&protocol.)=%str(EC-FV-04) | %str(&protocol.)=%str(EC-FV-06) %then %do; if studyweek<=24 & mod(studyweek,6)=0 then CT=1; else if studyweek>24 & mod(studyweek,8)=0 then CT=1; %end; %if %str(&protocol.)=%str(EC-FV-07) %then %do; if mod(studyweek,6)=0 then CT=1; %end; MINDT=ctdt-4; MAXDT=ctdt+4; format mindt maxdt date9.; if CT=1; drop CT; run; %mend CTSCHEDULE; %ctschedule(protocol=%str(EC-FV-04),drugstartdt=06JAN2014);
... View more