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!!
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;
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!!
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.