With the below code I'm having a weird behaviour in the log. According to the ampersand logics, the sequence of compilation for the macro variable derived from the combination
&&&&&&fix2&&&prefix&i
should be the following:
&&&fix2&life0>&p95within0>720.
However in the log of the code below blank spaces are filled in the step where, according to compilation logics, the code should execute the macro variable &p95within0. I need to understand why the compiler is not executing the last macro, filling blanks between the number "0" and the "p95within" prefix
%macro lapses;
%let fix2=p95within;
%do i=1 %to &dist;
proc sort data=not_assigned%cmpres(&&&prefix&i);
by account_id interaction_status_date;
run;
/*** separate sequence using within quantiles ****/
/** count variable created represent the sequence number **/
data not_assigned%cmpres(&&&prefix&i) (drop=lag_prev) ;
set not_assigned%cmpres(&&&prefix&i) ;
format lag_prev date9.;
by account_id ;
lag_prev=lag(prev_inter);
if first.account_id then count=1;
/** if greater the lapse than q95 BUT same date as previous interaction then do
not increase sequence **/
else if lapse_inter_prev > &&&&&&fix2&&&prefix&i and
lag_prev^=prev_inter then count+1;
run;
%end;
%mend lapses;
%lapses;
/************ LOG ******************/
MLOGIC(LEFT): Ending execution.
MLOGIC(CMPRES): Ending execution.
MPRINT(LAPSES): not_assigned0 ;
MPRINT(LAPSES): format lag_prev date9.;
MPRINT(LAPSES): by account_id ;
MPRINT(LAPSES): lag_prev=lag(prev_inter);
MPRINT(LAPSES): if first.account_id then count=1;
SYMBOLGEN: && resolves to &.
SYMBOLGEN: && resolves to &.
SYMBOLGEN: && resolves to &.
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable PREFIX resolves to life
SYMBOLGEN: Macro variable I resolves to 1
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable FIX2 resolves to p95within
SYMBOLGEN: Macro variable LIFE1 resolves to 0
NOTE: Line generated by the macro variable "LIFE1".
64 &p95within 0
_
390
200
76
WARNING: Apparent symbolic reference P95WITHIN not resolved.
MPRINT(LAPSES): else if lapse_inter_prev > &p95within 0 and lag_prev^=prev_inter then count+1;
MPRINT(LAPSES): run;
ERROR 390-185: Expecting an relational or arithmetic operator.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 76-322: Syntax error, statement will be ignored.
This
SYMBOLGEN: Macro variable LIFE1 resolves to 0
is your clue. &life1 contains the blanks. Make sure that it does not contain leading blanks by either doing
%let life1=&life1;
somewhere before you use it, or by using either the strip() or left() function (or the call symputx() routine) when creating it.
This
SYMBOLGEN: Macro variable LIFE1 resolves to 0
is your clue. &life1 contains the blanks. Make sure that it does not contain leading blanks by either doing
%let life1=&life1;
somewhere before you use it, or by using either the strip() or left() function (or the call symputx() routine) when creating it.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.