BookmarkSubscribeRSS Feed
max00d
Obsidian | Level 7
In my example I have a data set the I want to retrieve for a certain time period to perform further analysis on. In order to get the correct data set there a number of date variables that are used to speficy the ranges of various variables. However, as far as the user is concerned they only want data for a specific time period, e.g. month. Therefore, it seems over complicated to prompt them for a number of different dates to specify.

So if I create a parameter that prompts the user for a specific month is it possible to use some code somewhere to convert this month into the variables I require further down the line in my queries.

For example the user enter Jan and it is storer in the parameter &Month. Can I then create date value parameters such as &MonthStart (equal to 01Jan2010) and &MonthEnd (equal to 31Jan2010). This example is a simplification but does illustrate what I would like to do - is this possible? Thanks.
1 REPLY 1
RichardH_sas
SAS Employee
First off, are you running EG 4.1 or EG 4.2? EG 4.2 has some nice additions to date prompts, including support for intervals like month and year.

If you're using EG 4.2, try the following:

1. Select View / Prompt Manager.
2. Click Add to begin creating a new prompt. After picking a name etc., go to the second tab. Make it a date prompt, user enters values, date type of Month.

When the prompt gets used, it will create serveral macro variables behind the scenes. Let's say, for example, you called your prompt MP_new. After supplying a prompt value like January 2003, the code behind the scenes would have the following macro variable values available:

1. MP_new_label = January 2003
2. MP_new= 01Jan2003
3. MP_new_end = 31Jan2003

Using a filter in the query builder, you could then create an advanced filter. If you column was date_column_1 then:

date_column_1 between "&MP_new"d and "MP_new_end"d

Sadly, I don't see a point-and-click way to easily create this filter... but at least the month prompt interface makes choosing a value easier. Someone else on the forum might have a slicker solution for the filter part.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 980 views
  • 0 likes
  • 2 in conversation