SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
vishalrajpoot3
Obsidian | Level 7

 

Please help me to get the 6 month next date and previous date from the below dates.  Also suggest me where I am mistaking?

 

 

Set-A

Migration_Date

1-Oct-10
1-Jun-10
1-Apr-11
1-Oct-10
1-Nov-10
1-Jun-10
1-Oct-10
1-Jan-14
1-Mar-11

 

 

data date_treat;
set A;
sixmonth_backdt=intnx('month','Migration_dt'd,-6,'B');
format sixmonth_backdt date9.;
run;

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20
data Set_A;
input Migration_Date:date7.;
format Migration_Date date7.;
datalines;
1-Oct-10
1-Jun-10
1-Apr-11
1-Oct-10
1-Nov-10
1-Jun-10
1-Oct-10
1-Jan-14
1-Mar-11
;

data want;
   set Set_A;

   /* Exactly six months back */
   sixmonth_backdt=intnx('month',Migration_Date,-6,'S');

   /* Six months back, start of month */
   sixmonth_backdt_b=intnx('month',Migration_Date,-6,'B');

   /* The day before */
   The_Day_Before=Migration_Date-1;

   format _numeric_ date7.;

run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1 reply
  • 7353 views
  • 1 like
  • 2 in conversation