Help using Base SAS procedures

>= current

Reply
Regular Contributor
Regular Contributor
Posts: 238

>= current

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???

Super User
Posts: 11,343

>= current

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().

Regular Contributor
Regular Contributor
Posts: 238

>= current

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

Regular Contributor
Regular Contributor
Posts: 238

>= current

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

Frequent Contributor
Posts: 110

>= current

makesure both datepart(market_row_eff_dt),

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

Super User
Super User
Posts: 7,076

>= current

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.)

Regular Contributor
Regular Contributor
Posts: 238

>= current

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

PROC Star
Posts: 7,492

>= current

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

Super User
Posts: 11,343

>= current

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

Ask a Question
Discussion stats
  • 8 replies
  • 244 views
  • 0 likes
  • 5 in conversation