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.

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
  • 1 reply
  • 529 views
  • 0 likes
  • 2 in conversation