BookmarkSubscribeRSS Feed

Different Date Formats code

Started ‎06-10-2014 by
Modified ‎10-05-2015 by
Views 1,008

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:

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Labels
Article Tags