BookmarkSubscribeRSS Feed

Different Date Formats code

Started ‎06-10-2014 by
Modified ‎10-05-2015 by
Views 882

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

 

 

Version history
Last update:
‎10-05-2015 03:48 PM
Updated by:

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!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags