Where clause usage in %if in macro

  • Follow


Hi

I am using a %if condition to test a condtion in a macro . If the
condition is true I run a proc sql statement with WHERE clause inside
thte %if statement.

Surprising I get a ERROR message for the first pass "ERROR 180-322:
Statement is not valid or it is used out of proper order." and the
WHERE statement and create statement are underlined....

The structure loks like

%macro  abcd(v,t,c,e);

%if ( "&t." = "D" ) %then %do;

%do i =  &min. %to &max.  ;
		proc surveyselect data = xxxxxxxxx method = SRS rep = 1
		sampsize = 1  seed = -1 out = A ;
		  id _all_;
              where  val  = 10   and val 2 =2;
		run;
		quit;

%end;

%end;
%else;
               %do;

proc surveyselect data = yyyyyyyyyyyyy  method = SRS rep = 1
 sampsize = 1  seed = -1 out = qwert. ;

   where  val  = 10   and val 2 =2 and val3 = 45;
                 %end;






%mend;
%abcd(v,t,c,e);
0
Reply Aj 6/25/2010 9:35:05 AM

I can't find this PROC SQL in the code you've posted.

There second PROC SURVEYSELECT is not finished. Where is the run/quit?
0
Reply Patrick 6/25/2010 10:46:04 AM


Also: In the first where statement (where  val  = 10   and val 2 =2;)
is a blank between "VAL" and "2". This might be the reason for the
error you get.
0
Reply Patrick 6/25/2010 10:49:56 AM

Also you have an extra semi-colon after you last %ELSE
I assume that you wanted

%ELSE %DO;
  proc surveyselect  ....

%END;
0
Reply Tom 6/27/2010 5:07:20 AM

3 Replies
429 Views

(page loaded in 0.058 seconds)

Similiar Articles:













7/21/2012 7:57:39 PM


Reply: