Desktop productivity for business analysts and programmers

Date Criteria for Current Date in a SAS EG Query Expression

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Date Criteria for Current Date in a SAS EG Query Expression

I'm a new convert from Access and very green on EG.  I'm trying a simple query formula where I need records from the past 60 days.  The criteria in Access was simply Date()-60.  What does the filter look like in a SAS EG query?


Accepted Solutions
Solution
‎05-01-2017 02:32 PM
PROC Star
Posts: 1,143

Re: Date Criteria for Current Date in a SAS EG Query Expression

[ Edited ]

Almost identical:

 

Using the dataset SASHELP.STOCKS as an example:

 

1. Create a new query, select the variables you want.

 

2. On the filter tab, create a new filter, and select an advanced filter.

 

3. Your filter text should be something like

 

t1.Date >= (today() - 4501)

 

(this will select all the records with date later than Jan 1, 2005).

 

4. Next, then Finish

 

5. Run your query.

 

Make sure the integer you use gets you exactly the dates you want...testing is important!

Tom

View solution in original post


All Replies
PROC Star
Posts: 7,428

Re: Date Criteria for Current Date in a SAS EG Query Expression

Depends upon whether you are using the GUI. A youtube video shows various ways to select using the GUI: https://www.youtube.com/watch?v=rNseN9tGfwM

 

Otherwise, you may only need something like between today() and today()-60

 

Art, CEO, AnalystFinder.com

 

Generate a date range prompt for only 2011 data and apply to the data table.
Solution
‎05-01-2017 02:32 PM
PROC Star
Posts: 1,143

Re: Date Criteria for Current Date in a SAS EG Query Expression

[ Edited ]

Almost identical:

 

Using the dataset SASHELP.STOCKS as an example:

 

1. Create a new query, select the variables you want.

 

2. On the filter tab, create a new filter, and select an advanced filter.

 

3. Your filter text should be something like

 

t1.Date >= (today() - 4501)

 

(this will select all the records with date later than Jan 1, 2005).

 

4. Next, then Finish

 

5. Run your query.

 

Make sure the integer you use gets you exactly the dates you want...testing is important!

Tom

New Contributor
Posts: 2

Re: Date Criteria for Current Date in a SAS EG Query Expression

Worked perfect! Much appreciated!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 208 views
  • 0 likes
  • 3 in conversation