Hi all,
I am struggling to fix this bit of code . Could someone help me please ?
Many thanks in advance.
%let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
data _null_;
date2=intnx("month",&today.,-1,'end');
put date2=;
call symputx('DATE2',put(&date2. ,date9.));
%put DATE2=&date2.;
month_id = intck('month','01jan1990'd,today());
put month_id=;
call symputx('month_id',month_id);
%put month_id=&month_id.;
run;LOG FILE:
23 GOPTIONS ACCESSIBLE;
24
25
26 %let today=%sysfunc(today());
27 %let currdt=%sysfunc(datetime());
28 data _null_;
29
30 date2=intnx("month",&today.,-1,'end');
31 put date2=;
32 call symputx('DATE2',put(&date2. ,date9.));
NOTE: Line generated by the macro variable "DATE2".
32 31JAN2020
_______
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,
LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
33 %put DATE2=&date2.;
DATE2=31JAN2020
34
35 month_id = intck('month','01jan1990'd,today());
36 put month_id=;
37 call symputx('month_id',month_id);
38 %put month_id=&month_id.;
month_id=361
39
40 run;
Take care of proper naming of variables in the data step, and of macro timing. The data step needs to RUN to populate the macro variables, so you must not use %put IN the data step:
%let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
data _null_;
date2=intnx("month",&today.,-1,'end');
put date2=;
call symputx('DATE2',put(date2 ,date9.));
month_id = intck('month','01jan1990'd,today());
put month_id=;
call symputx('month_id',month_id);
run;
%put &=date2;
%put &=month_id;
date2 is not a macro variable
%let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
data _null_;
date2=intnx("month",&today.,-1,'end');
put date2=;
call symputx('DATE2',put(date2 ,date9.));
%put DATE2=&date2.;
month_id = intck('month','01jan1990'd,today());
put month_id=;
call symputx('month_id',month_id);
put month_id=&month_id.;
run;
Take care of proper naming of variables in the data step, and of macro timing. The data step needs to RUN to populate the macro variables, so you must not use %put IN the data step:
%let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
data _null_;
date2=intnx("month",&today.,-1,'end');
put date2=;
call symputx('DATE2',put(date2 ,date9.));
month_id = intck('month','01jan1990'd,today());
put month_id=;
call symputx('month_id',month_id);
run;
%put &=date2;
%put &=month_id;
Hi @jorquec
Another way to do this:
%let today=%sysfunc(today());
%let currdt=%sysfunc(datetime());
%let date= %sysfunc(intnx(month,&today., -1,e),date9.);
%let month_id= %sysfunc(intck(month,'01jan1990'd,&today.));
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 lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.