1) Start_date is a date value. If you want a DATETIME value you need to make one. Easiest is
DateTimeValue = DHMS(today(),0,0,0); to make one with zero for hour, minute and second.
If you want it for the day before
DateTimeValue = DHMS(today() -1,0,0,0); (or use INTNX function)
To get a macro variable with a DATETime appearance then you need to specify a DATETIME format with PUT. Since you know that you want datetime25.6
Call symput('dt',put(Datetimevalue,datetime15.6));
Some other things, If you use Call Symput('dt', ..) twice as shown only the last value will be kept. You need separate macrovariable names, perhaps dtstart and dtend.
Thing very carefully about using quotes in the actual definition of a macro variable. Also HOW exactly will you use the resulting macrovariables? If for titles or text you would not want the quotes. If for comparisons with other datetime valued variables you don't need to use a datetime format as the numeric value would work.
Your comment: It doesn't bring any info because the data that I'm pulling from is a datetime 25.6
doesn't have any meaning in the context presented. You are assuming we know a lot more than has been shown.
Hi mate.
%let tdate = %sysfunc(today(),datetime25.6);
%put &tdate.;
Is this what you need ?
Hope this helps
1) Start_date is a date value. If you want a DATETIME value you need to make one. Easiest is
DateTimeValue = DHMS(today(),0,0,0); to make one with zero for hour, minute and second.
If you want it for the day before
DateTimeValue = DHMS(today() -1,0,0,0); (or use INTNX function)
To get a macro variable with a DATETime appearance then you need to specify a DATETIME format with PUT. Since you know that you want datetime25.6
Call symput('dt',put(Datetimevalue,datetime15.6));
Some other things, If you use Call Symput('dt', ..) twice as shown only the last value will be kept. You need separate macrovariable names, perhaps dtstart and dtend.
Thing very carefully about using quotes in the actual definition of a macro variable. Also HOW exactly will you use the resulting macrovariables? If for titles or text you would not want the quotes. If for comparisons with other datetime valued variables you don't need to use a datetime format as the numeric value would work.
Your comment: It doesn't bring any info because the data that I'm pulling from is a datetime 25.6
doesn't have any meaning in the context presented. You are assuming we know a lot more than has been shown.
Please show the code actually used to generate the macro value AND the code where you attempt to use the variable and the log.
And did you pay attention to the use of DHMS to create an actual DATETIME type variable in the code I posted previously?
Your example code using TODAY() generates a DATE, not a DATETIME. Since SAS stores dates as number of days since 1 Jan 1960 and DATETIME as number of SECONDS there are significant differences of the results when you treat a date, as in your example, as if it were a datetime.
There's a standard remedy for this type of problem. Get the program to work without using any macro language. Once you figure out what Teradata is looking for, it won't be hard to turn that into a macro. But you have to have a working program first.
You still are not showing the code USING the macro variables. The error message looks incomplete. If the Error is in the log then copy the code and error from the log post it.
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!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: