BookmarkSubscribeRSS Feed
tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

I have to create my query so that my date is >= today and I have

market_row_eff_dt >=                  not sure what to put in???

8 REPLIES 8
ballardw
Super User

you may be looking for: Date() which returns the current date. BUT your variable name ending in DT makes me think you are actually comparing a DATETIME value, not a date. if that is the case you may be looking for DATEPART(market_row_eff_dt) ge Date().

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

I cannot get this to work within my proc sql code. I put a bit below of what I have.

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

So in my proc sql code I have

proc_cd in (&ortho)

and

datepart(market_row_eff_dt) >= date()

???

I cannot use get in the SQL statement

sassharp
Calcite | Level 5

makesure both datepart(market_row_eff_dt),

date() should be in same format. otherwise you get error.

Tom
Super User Tom
Super User

You can use DATE() to get today's date and DATETIME() to get the current time as a datetime value.

You can also use &SYSDATE9 to get the date that the program session started. and &SYSTIME to get the time it started.

You can specify a date literal in SAS by using quoted string followed by the letter d. Use the date. format.  For example today is
"06MAR2012"d

For datetime use dt as the suffix.  "01MAR2012:14:18"dt

You can use %SYSFUNC to let you call DATE() and generate the string.

"%sysfunc(date(),date9.)"d

Are you referencing an external database? or just referencing SAS datasets?  Different databases will have different ways of storing dates (datetime versus date only for example) and specifying a specific date (does it use ddMMMyyyy format like SAS or does it want YYYYMMDD or some other format.)

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

well this is my fix

market_row_eff_dt >= current date

no () no ' just current date typed as u see and a space between. how odd. guess that is how DB2 handles it

art297
Opal | Level 21

Not odd.  That is how DB2 specifies it.  Take a look at: http://www.ibm.com/developerworks/data/library/techarticle/0211yip/0211yip3.html

ballardw
Super User

And you never bothered to let us know you were reading DB2 files. All of the above solutions work on SAS datasets.

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 8 replies
  • 1972 views
  • 0 likes
  • 5 in conversation