We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Different Date Formats code

by Regular Learner Anind_Sharma on ‎06-10-2014 02:51 AM - edited on ‎10-05-2015 03:48 PM by Community Manager (300 Views)

data null;

format dt date9.;

d=put(month(today())-2,z2.);

if month(today())=1 then e=put(year(today())-1,4.);

else e=put(year(today()),4.);

f=e||d;

dt=input(put(f,6.),yymmn6.);

call symput ('Snapshot_date',intnx('month',dt,0,'e'));

run;

 

data null;

call symput ('L1M',put(intnx("month",&Snapshot_date,-1,'e'),date9.));

call symput ('L3M',put(intnx("month",&Snapshot_date,-3,'e'),date9.));

call symput ('L6M',put(intnx("month",&Snapshot_date,-6,'e'),date9.));

call symput ('L1Y',put(intnx("month",&Snapshot_date,-12,'e'),date9.));

call symput ('rpt_dte',put(&Snapshot_date,date7.));

call symput ('monyy',propcase(put(&Snapshot_date,monyy5.)));

call symput('Rbase2',put(intnx('month',&Snapshot_date,0,'e'),yymmddn8.));

run;

 

%put &Snapshot_date &L1M &L3M &l6M &L1Y &monyy &Rbase2;

 

 

Output#

 

19843 31MAR2014 31JAN2014 31OCT2013 30APR2013 Apr14 20140430

 

 

Your turn
Sign In!

Want to write an article? Sign in with your profile.


Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.