BookmarkSubscribeRSS Feed
SaraDob
Calcite | Level 5

Hello!

Still new to SAS world and certainly very new to date conversion.

The query I'm trying to run, has dates, that has to be changed every day. the date plugged inside the query has to be in yymmddN8 format( eg: 20180827)

can you please let me know how do you convert tSAS today() date to the above said format.

 

Also I have a condition to verify , if the today is friday, get today date and sunday date also.

Please help!

2 REPLIES 2
Reeza
Super User

@SaraDob wrote:

 

The query I'm trying to run, has dates, that has to be changed every day. the date plugged inside the query has to be in yymmddN8 format( eg: 20180827)

can you please let me know how do you convert tSAS today() date to the above said format.

 

Do you need that in a numeric or character variable?

 

 


@SaraDob wrote:

 

Also I have a condition to verify , if the today is friday, get today date and sunday date also.

Please help!


Look at INTNX for this one. WEEKDAY(TODAY()) returns the Weekday number, 1 being Sunday and 7 being Saturday. 

Are you looking for the Sunday after or before the Friday? If before, use a negative interval, if after, use a positive interval.

 

What about holidays?

 

 

ballardw
Super User

Is your value actually a numeric 20180827? Then it is not a date to SAS. Currently the largest valid number of days to treat as a date is around 6588970, about 14,000,000 less than your value.

 

If numeric then

input(put(today(),yymmddn8.),8.)

if character 

put(today(),yymmddn8.)

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 3515 views
  • 0 likes
  • 3 in conversation