DATA Step, Macro, Functions and more

SAS Macro DATE MACRO VARIABLE

Reply
N/A
Posts: 0

SAS Macro DATE MACRO VARIABLE

I am new to MACRO

Here's what I wrote to create
d1 as last month this year
d2 as last month last year

data _test_ ;
d1 = put(mdy(month(today())-1,1,year(today())-1),yymmdd10.);
call symput('d1',"'"||put(d1,9.)||" 23:59:59'") ;
d2 = put(mdy(month(today())-1,1,year(today())),yymmdd10.);
call symput('d2',"'"||put(d2,9.)||" 23:59:59'") ;
run ;

%put d1;

I successfully get the value : however when I look into my _test_ table it doesn't give me value that include " 23:59:59"

as well as when I was trying to use %put statment to show me value of d1 ,

What am I missing here ?

Thank you !
Super Contributor
Posts: 647

Re: SAS Macro DATE MACRO VARIABLE

this will display the resolved value of d1

%put &d1.;
N/A
Posts: 0

Re: SAS Macro DATE MACRO VARIABLE

Ah.. Thank you Phile
Super Contributor
Super Contributor
Posts: 3,174

Re: SAS Macro DATE MACRO VARIABLE

Given your SAS DATA step assignment code, suggest the OP look at using the INTNX function to derive (in one statement), a "last month period ending DATETIME" value, using "DTMONTH" as argument #1 and "END" as argument three.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

intnx function month ending date site:sas.com
SAS Employee
Posts: 58

Re: SAS Macro DATE MACRO VARIABLE

Yep, watch out for those missing ampersands...!
Ask a Question
Discussion stats
  • 4 replies
  • 158 views
  • 0 likes
  • 4 in conversation