BookmarkSubscribeRSS Feed
cho16
Obsidian | Level 7

Hi Team,

 

I am trying to run the below macro code and it gives an error.

 

I couldnt figure out the error. Could you please help me

 

%macro roster;

proc sql;

create table NON_RESPONDERS_BULLET_7_P as

select t1.* from DSS_HRA_Healthfirst_Roster t1

where (t1.EFFECTIVE_DATE < intnx('year',today(),-1,'S') OR t1.EFFECTIVE_DATE > intnx('year',today(),-1,'E'))

and (t1.PRODUCT_PBP CONTAINS 'LIP1' OR t1.PRODUCT_PBP CONTAINS 'MAX1')

and ((t1.LAST_SURVEY_DATE1 BETWEEN intnx('year',&start3mnth,-15) and intnx('year',&end3month,-15))

%do i = -14 %to -2;

or (t1.LAST_SURVEY_DATE1 BETWEEN intnx('year',&start3mnth,&i) and intnx('year',&end3month,&i))

%end;

or (t1.LAST_SURVEY_DATE1 BETWEEN intnx('year',&start3mnth,&i) and intnx('year',&end3month,&i)));

quit;

%mend roster;

%roster

 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <,
              <=, <>, =, >, >=, ?, AND, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE,
              LT, LTT, NE, NET, OR, ^=, |, ||, ~=.

 

 

5 REPLIES 5
Quentin
Super User

What are the values of &start3mnth and &end3month?

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
cho16
Obsidian | Level 7

Hi Quentin,

 

%put &end3month &start3mnth ;

/* 31AUG2015 01AUG2015 */

 

Reeza
Super User

Looking at a single line of code and what it would resolve to. This isn't valid SAS code. 

 

and ((t1.LAST_SURVEY_DATE1 BETWEEN intnx('year',&start3mnth,-15) and 
and ((t1.LAST_SURVEY_DATE1 BETWEEN intnx('year',01AUG2015,-15) and 

 

You need to provide those as date literals to the macro 

 

"&end3month"d

 

Change your code to allow your dates to resolve properly.  

ballardw
Super User

If you run the macro with the option mprint the error will appear in the log in a more useful location;

 

options mprint;

%roster;

 

Without data or values for your macro variables Start3Mnt and End3Month it's a bit hard to be more precise though if either of those is blank that could be a cause.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is it your trying to do.  Post test data in the form of a datastep and what the output should look like.  That block of code firstly doesn't need to be in a macro - all your seem to be doing is taking data where last_survey_date is between some set of months on 14 years to 2 years before.  This is simple logic and doesn't need 14 "or" clauses generated for it.  A simple datastep will also make life easier for you, but I can't post example code until you show your data and what its suppoed to look like.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 880 views
  • 0 likes
  • 5 in conversation