BookmarkSubscribeRSS Feed
SteelersPitts
Obsidian | Level 7

Hi All,

 

I've a table with "run date" field. Can anyone let me know how I can create a date range field?

 

For example:

If Run date is 7/18/2018 then in the weekday range column I need to show the value "7/15/2018-7/21/2018" 

 

Thank you for all the help!!

4 REPLIES 4
tomrvincent
Rhodochrosite | Level 12
Use INTNX function to add/subtract days from the run date.
novinosrin
Tourmaline | Level 20
data w;
k='18jul2018'd;
range=catx('-',put(intnx('WEEK',k,0,'b'),mmddyy10.),put(intnx('week',k,0,'e'),mmddyy10.));
format k mmddyy10.;
run;
Reeza
Super User

You need CATX and the INTNX functions.

 

The last parameter in the INTNX function is the alignment parameter. That tells SAS to return the beginning of a week or end of a week for example. So setting the interval to 0, means find the first and last of the week with the b/e alignment options. 

 

@novinosrin code illustrates this. 

 


@SteelersPitts wrote:

Hi All,

 

I've a table with "run date" field. Can anyone let me know how I can create a date range field?

 

For example:

If Run date is 7/18/2018 then in the weekday range column I need to show the value "7/15/2018-7/21/2018" 

 

Thank you for all the help!!


 

Astounding
PROC Star

All of these answers are sniffing in the right direction.  But you'll need to clarify the problem a bit.  What should the result be for these run dates?

 

7/20/2018

7/21/2018

7/22/2018

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 413 views
  • 3 likes
  • 5 in conversation