BookmarkSubscribeRSS Feed
fabdu92
Obsidian | Level 7

Hi,

 

I am stuck on an issue when I try to write a filter. The program doesn't log me errors, but  the filter is not taken into account.

I have 3 data:

# one date prompt named "pm"

# one date named "initial_date"

# one number named "duration"

 

I want to select only rows where the end of the month of initial_date+duration (months) >= pm

 

The filter I wrote is this one:

WHERE %_eg_WhereParam( INTNX('month', 
INITIAL_DATE, + DURATION , 'e'), PM, GE, TYPE=D, IS_EXPLICIT=0 );

Can you tell me where the mistake is?

 

Thank you by advance

4 REPLIES 4
Reeza
Super User

Your prompts are macro variables, you need to reference them with a & in front. 

 

WHERE %_eg_WhereParam( INTNX('month', 
&INITIAL_DATE, &DURATION , 'e'), PM, GE, TYPE=D, IS_EXPLICIT=0 );

 

I can't guarantee that will work since I don't know what the parameters look like or your data. They do have to line up and the code generated needs to be valid SAS code.

 

You don't need the + sign in front of duration.

 

Usually in macros you don't have the parameters in quotes (month and e) but I'm not familiar with the EG filter macro being used.

 

Hopefully this helps get you started. 

fabdu92
Obsidian | Level 7

Thank you for your answer but yo misunderstood: 

My prompt is PM, Initial_date and duration are data gotten from a previous task.

Reeza
Super User

Did you try the method with PM? What does your filter look like now?

 

%put &8pm;

fabdu92
Obsidian | Level 7

Hey Reeza,

 

I've tried differently but always the same problem...

When I put PM, I have the result expected, that means "31MAY2016"

 

Now I have calculated on the previous task a new data:

*DT_END

which is equals to 

INTNX('month', 
INITIAL_DATE, + DURATION , 'e')

 

This is working.

 

So on my filter I do:

WHERE %_eg_WhereParam( DT_END, PM, GE, TYPE=D, IS_EXPLICIT=0 );

 And still with this, it's like I have not written this filter...It output all rows not only those where DT_END >= PM

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
  • 4 replies
  • 1329 views
  • 0 likes
  • 2 in conversation