Dears, I am new with SAS Macro, i have created a basic procedure in oracle, and need to have it in SAS as well, Oracle Procedure, Declare w1 number := 0; w2 number := 0; w3 number := 0; w4 number := 0; BEGIN LOOP update io_campaign a set a.n_type='T' where rowid in ( select rowid from io_campaign b where b.n_type='T' and rownum <=5 order by DBMS_RANDOM.RANDOM); COMMIT; update io_campaign a set a.n_type='C' where rowid in( select rowid from io_campaign a where a.n_type='T' rownum <=5 order by DBMS_RANDOM.RANDOM); commit; select a.TOTAL_W1, a.TOTAL_W2, a.TOTAL_W3, a.TOTAL_W4 into w1, w2, w3, w4 from precision_factor a where a.campaign_id='CAMP1539' and A.N_TYPE='PRECISION_FACTOR' AND A.EXEC_DATE=TRUNC(SYSDATE); EXIT WHEN W1 between 0.97 AND 1.03 and W4 between 0.97 AND 1.03 and W2 between 0.97 AND 1.03 and W3 between 0.97 AND 1.03 ; END LOOP; END; In SAS I have it like below and it is not working %Macro abc; libname mkt oracle path=mkt SCHEMA=XXXXX USER=XXXXX PASSWORD="XXXXXX"; proc sql; %let w1 = 1.5; %let w2 = 0.96; %let w3 = 1.23; %let w4 = 0.34; %let a = 1.03; %let b = 0.97; select a.TOTAL_W1, a.TOTAL_W2, a.TOTAL_W3, a.TOTAL_W4 into :w1, :w2, :w3, :w4 from mkt.precision_factor a where a.campaign_id="CAMP1545" and A.N_TYPE='PRECISION_FACTOR' AND datepart(A.EXEC_DATE)=today(); %DO %WHILE((&w1 between '&b' and '&a' ) and (&w2 between '&b' and '&a' ) and (&w3 between '&b' and '&a' ) and (&w4 between '&b' and '&a' )); update mkt.io_campaign set n_type='T' where subs_id in ( select x.subs_id from (select a.subs_id,ranuni(count(*)) as nn from mkt.io_campaign a where a.campaign_id="CAMP1545" and a.n_type='C' and datepart(exec_Date)=today()-3 and monotonic() le 7)x); update mkt.io_campaign set n_type='C' where subs_id in ( select b.subs_id from (select a.subs_id,ranuni(count(*)) as nn from mkt.io_campaign a where a.campaign_id="CAMP1545" and a.n_type='T' and datepart(exec_Date)=today()-3 and monotonic() le 7)b); select a.TOTAL_W1, a.TOTAL_W2, a.TOTAL_W3, a.TOTAL_W4 into :w1, :w2, :w3, :w4 from mkt.precision_factor a where a.campaign_id="CAMP1545" and A.N_TYPE='PRECISION_FACTOR' AND datepart(A.EXEC_DATE)=today(); %put &w1 &w2 &w3 &w4; %END; run; %MEND abc; and receiving following ERROR ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: (&w1 between '&b' and '&a' ) and(&w2 between '&b' and '&a' ) and (&w3 between '&b' and '&a' ) and (&w4 between '&b' and '&a' ) ERROR: The condition in the %DO %WHILE loop, (&w1 between '&b' and '&a' ) and(&w2 between '&b' and '&a' ) and (&w3 between '&b' and '&a' ) and(&w4 between '&b' and '&a' ), yielded an invalid or missing value, . The macro will stop executing. ERROR: The macro ABC will stop executing.
... View more