Hi Guys!
My first post here. So please tell me if there are any rules/principles to follow while posting in this community.
I want to compare a string (which comes from user) to a fixed string inside a macro.
I wanted to use SAS function "compare" but it gives me error.
Here is the relevant code and log
code (from where user call the macro):
%include "E:\Excel Conversion Project\variable analysis\VarAnalysis.sas";
%let SpecialValues= -1, -2, -3, 1, 2 ,3, 9998, 9999, 9000, 9001, 9002, 9003, 8400, 8401, 8402, 8403, 9399, 9398, -599, -598, -597;
ods csv file= "E:\Excel Conversion Project\variable analysis\GD_exampledata_vantage.csv";
%varAnalysis(data1.exampledata, BG90, 1, 10, 1, 1, vantage);
ods csv close;
code (macro):
%macro varAnalysis(InputDataset, DependentVar, Weights, NumOfBuckets, IsNegative, RemoveSpecialValues, PredictorVar);
%if compare(&PredictorVar,allvars, 'i') = 0 %then
%getGraphDataAllVar(&InputDataset, &DependentVar, &Weights, &NumOfBuckets, &IsNegative, &RemoveSpecialValues);
%else
%getGraphData(&InputDataset, &DependentVar, &Weights, &NumOfBuckets, &IsNegative, &RemoveSpecialValues, &PredictorVar);
%mend varAnalysis;
log:
505 %include "E:\Excel Conversion Project\variable analysis\VarAnalysis.sas";
NOTE: Libref DATA1 was successfully assigned as follows:
Engine: V9
Physical Name: E:\Excel Conversion Project\testing
NOTE: Libref DATA2 was successfully assigned as follows:
Engine: V9
Physical Name: E:\Excel Conversion Project\testing\temp(to be deleted)
NOTE: Libref DATA3 was successfully assigned as follows:
Engine: V9
Physical Name: E:\Excel Conversion Project
748
749 %let SpecialValues= -1, -2, -3, 1, 2 ,3, 9998, 9999, 9000, 9001, 9002, 9003, 8400, 8401, 8402,
749 ! 8403, 9399, 9398, -599, -598, -597;
750
751 ods csv file= "E:\Excel Conversion Project\variable analysis\GD_exampledata_vantage.csv";
NOTE: Writing CSV Body file: E:\Excel Conversion Project\variable analysis\GD_exampledata_vantage.csv
752
753 %varAnalysis(data1.exampledata, BG90, 1, 10, 1, 1, vantage);
MLOGIC(VARANALYSIS): Beginning execution.
MLOGIC(VARANALYSIS): Parameter INPUTDATASET has value data1.exampledata
MLOGIC(VARANALYSIS): Parameter DEPENDENTVAR has value BG90
MLOGIC(VARANALYSIS): Parameter WEIGHTS has value 1
MLOGIC(VARANALYSIS): Parameter NUMOFBUCKETS has value 10
MLOGIC(VARANALYSIS): Parameter ISNEGATIVE has value 1
MLOGIC(VARANALYSIS): Parameter REMOVESPECIALVALUES has value 1
MLOGIC(VARANALYSIS): Parameter PREDICTORVAR has value vantage
SYMBOLGEN: Macro variable PREDICTORVAR resolves to vantage
ERROR: Required operator not found in expression: compare(&PredictorVar,allvars, 'i') = 0
ERROR: The macro VARANALYSIS will stop executing.
MLOGIC(VARANALYSIS): Ending execution.
754
755 ods csv close;
PS: In case I use %if &PredictorVar = allvars %then
the code runs fine. I wanted to use compare function to ignore case, extra spaces etc.
Message was edited by: grvs