Hello SAS community, I need help fixing my code, I am trying to writing a code that evaluates the performance of certains observations in my data over several monthly periods. I created a code that works but a bit tedious. To evaluate a perfomance over 12 months, I manually count 12 periods to find the ending date. As follow: January - beginning_date=201701 - ending_date=201712 February - beginning_date=201702 - ending_date=201801 etc... Here's my sample code below: %beginning_date= 201701;
%ending_date= 201712;
PROC SQL;
CREATE TABLE PERFORMANCE AS
SELECT t1.*,
t2.*
FROM DATA_X t1
LEFT JOIN DATA_Y t2 ON(t1.A=t2.B)
WHERE t2.DATE BETWEEN &beginning_date. AND &ending_date.;
QUIT; I am now looking for a way to automate the counting process so that I can a performance over a 12, 18, 24 months. I used the code below but I am getting the following error message: ERROR 22-322: Syntax error, expecting one of the following: !!, *, **, +, -, /, AND, ||. ERROR 76-322: Syntax error, statement will be ignored. The DATE variable in my table is numeric not sure with values such as year/month 201701, 201702, etc.. Any idea or suggestions, thanks 🙂 %let beginning_date=201701 ;
*Macro variable date;
DATA _null_;
DATE=&beginning_date.;
CALL SYMPUT("date_begin_perfo12", PUT(INTNX('month',input("&beginning_date.",yymmn6.),0,'end'),Date9.));
CALL SYMPUT("date_end_perfo12", PUT(INTNX('month',input("&beginning_date.",yymmn6.),+12,'end'),Date9.));
RUN;
%put &date_begin_perfo12.;
%put &date_end_perfo12.;
PROC SQL;
CREATE TABLE PERFORMANCE AS
SELECT t1.*,
t2.*
FROM DATA_X t1
LEFT JOIN DATA_Y t2 ON(t1.A=t2.B)
WHERE t2.DATE BETWEEN &date_begin_perfo12. AND &date_end_perfo12.;
QUIT;
... View more