DATA Step, Macro, Functions and more

Compare intnx and prompt

Reply
Contributor
Posts: 42

Compare intnx and prompt

[ Edited ]

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

Super User
Posts: 19,878

Re: Compare intnx and prompt

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. 

Contributor
Posts: 42

Re: Compare intnx and prompt

Thank you for your answer but yo misunderstood: 

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

Super User
Posts: 19,878

Re: Compare intnx and prompt

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

 

%put &8pm;

Contributor
Posts: 42

Re: Compare intnx and prompt

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

Ask a Question
Discussion stats
  • 4 replies
  • 350 views
  • 0 likes
  • 2 in conversation