BookmarkSubscribeRSS Feed
JDMTX
Fluorite | Level 6

I have created a dynamic prompt in my project that allows the user to select a date (ex:  15Dec2012) and then this prompt to to subset the data via the use of a query filter.  Is there away to create a second prompt that calculates back exactly one month from the user selected value in the first prompt so that I can create a second data subset that containts only the data for the prior month (ex:  15Nov2012)?

Any help is deeply appreciated.

Many Thanks,

James

4 REPLIES 4
TomKari
Onyx | Level 15

Hi, James

Is there any reason for you to prompt the user? Or do you simply want to calculate the date one month earlier, to use as a lower bound?

Tom

JDMTX
Fluorite | Level 6

Tom,

In this particular usage case, the user of the project needs to be able to select the month that they are interested in and then using this informatin calculate back one month so that we can produce a report that segments the data by current analysis period and the prior month on a dynamic basis.

Regards,

James

Astounding
PROC Star

James,

The basic tool for the job is the INTNX function, something along the lines of:

begin_date = intnx('month', "&userdate"d, -1);

Look at the 4th parameter to INTNX as well, which lets  you select SAME to get the same day of the month.  Think about what you want to happen if the user specifies a date designating an uncertain time period, such as February 28th, or March 30th.  The way that INTNX handles this with SAME may or may not correspond to the time period you would like to select.

Good luck.

JDMTX
Fluorite | Level 6

Astounding,

Your approach worked perfectly.  Thanks for the help!!!

James

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 792 views
  • 0 likes
  • 3 in conversation