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

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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