i have the following code. when i run the code the macro doesn't create the correct date
code:
rsubmit;
%macro campaign(pilot,pre,post);
DATA test;
set saayma_a.&pilot. (obs=1 keep=dte);
call symput('Start_Date1',put(intnx('month',dte,-%eval(+&pre.)),YYMMN6.));
call symput('End_Date1',put(intnx('month',dte,-%eval(-&post.)),YYMMN6.));
run;
%put &Start_Date1 &End_Date1;
%DO Do_Date=&Start_Date1 %TO &End_Date1 %BY 1;
DATA _NULL_;
CALL SYMPUT('date',(&do_date));
RUN;
%put &date;
DATA saayma_a.camp_&pilot._svoc&date.;
length msisdn $15.;
merge saayma_a.&pilot._&date. ( in=a drop=cp23_identity_number dob)
saayma_a.svoc2_m&date. ( in=b keep=msisdn SBM_Capable_Category customer_segment Most_Priceplan
Most_Cell_Province HANDSET_SmartPhone Me2U_mProfile
sbm_payment_type sbm_priceplan_final
M1_Total_Cost M1_Total_Spend M1_Total_Revenue M1_Total_Value
M1_Total_Data_Bundle_Cost M1_GPRS_MBytes M1_Recharge_Count
M1_Recharge_Value M1_Post_CB M1_PrePaid_CB IC_No_In_Peak_Calls
IC_No_In_OffPeak_Calls IC_Inbound_Calls IC_Inbound_Cost
IC_No_Out_Peak_Calls IC_No_Out_OffPeak_Calls IC_Outbound_Calls
IC_Outbound_Cost );
by msisdn;
if a;
svoc_date=&date.;
run;
%END;
%mend campaign;
%campaign(Pilot2607,1,1);
endrsubmit;
Error log:
NOTE: Compression was disabled for data set WORK.TEST because compression overhead would increase the size of the data
set.
NOTE: There were 1 observations read from the data set SAAYMA_A.PILOT2607.
NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.14 seconds
cpu time 0.01 seconds
201309 201311
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
521:1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
201309
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.camp_Pilot2607_svoc 201309
------
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.Pilot2607_ 201309
------
22
200
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.svoc2_m 201309
------
22
200
ERROR: File SAAYMA_A.PILOT2607_.DATA does not exist.
ERROR: File SAAYMA_A.SVOC2_M.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, END, _DATA_, _LAST_,
_NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Compression was disabled for data set SAAYMA_A.CAMP_PILOT2607_SVOC because compression overhead would increase the
size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SAAYMA_A.CAMP_PILOT2607_SVOC may be incomplete. When this step was stopped there were 0
observations and 2 variables.
WARNING: Data set SAAYMA_A.CAMP_PILOT2607_SVOC was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
521:1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
201310
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.camp_Pilot2607_svoc 201310
------
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.Pilot2607_ 201310
------
22
200
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.svoc2_m 201310
------
22
200
ERROR: File SAAYMA_A.PILOT2607_.DATA does not exist.
ERROR: File SAAYMA_A.SVOC2_M.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, END, _DATA_, _LAST_,
_NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Compression was disabled for data set SAAYMA_A.CAMP_PILOT2607_SVOC because compression overhead would increase the
size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SAAYMA_A.CAMP_PILOT2607_SVOC may be incomplete. When this step was stopped there were 0
observations and 2 variables.
WARNING: Data set SAAYMA_A.CAMP_PILOT2607_SVOC was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
521:1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
201311
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.camp_Pilot2607_svoc 201311
------
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.Pilot2607_ 201311
------
22
200
NOTE: Line generated by the macro variable "DATE".
521 saayma_a.svoc2_m 201311
------
22
200
ERROR: File SAAYMA_A.PILOT2607_.DATA does not exist.
ERROR: File SAAYMA_A.SVOC2_M.DATA does not exist.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, -, :, ;, END, _DATA_, _LAST_,
_NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Compression was disabled for data set SAAYMA_A.CAMP_PILOT2607_SVOC because compression overhead would increase the
size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SAAYMA_A.CAMP_PILOT2607_SVOC may be incomplete. When this step was stopped there were 0
observations and 2 variables.
WARNING: Data set SAAYMA_A.CAMP_PILOT2607_SVOC was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: Remote submit to MTNX290.UATSPAWN complete.
You have more parentheses than you need in
CALL SYMPUT('date',(&do_date));
Even without those extras, the effect is providing the macro variable as a number. Try :
CALL SYMPUT('date',"&do_date");
I think those extra parentheses cause evaluation, when all you want is a string constant for that CALL routine. Those double quotes permit the macro variable to be resolved while being quoted like a string. The numeric result of the evaluation has to be converted to a string and the default is BEST12. So you get leading zeroes. You want only the text in that macro variable so treat it as a string "&do-date"
You might find another problem when your START and END straddle a year-end. That will/might happen when the variable DTE has a january or december date
good luck
You have more parentheses than you need in
CALL SYMPUT('date',(&do_date));
Even without those extras, the effect is providing the macro variable as a number. Try :
CALL SYMPUT('date',"&do_date");
I think those extra parentheses cause evaluation, when all you want is a string constant for that CALL routine. Those double quotes permit the macro variable to be resolved while being quoted like a string. The numeric result of the evaluation has to be converted to a string and the default is BEST12. So you get leading zeroes. You want only the text in that macro variable so treat it as a string "&do-date"
You might find another problem when your START and END straddle a year-end. That will/might happen when the variable DTE has a january or december date
good luck
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.