I want to convert today() in charakter.
My idea was:
%Let Mydate="put(today() date9.)" ;
But it seems I have an error in my thinking.
You mix up several things :
- macro instructions/functions (beginning with %)
- base sas language, data step functions.
You can use a datastep function in a macro instruction with %sysfunc.
If you want to create a variable in a dataset with today's date :
data have;
myDate=put(today(), date9.);
put myDate=;
run;
If you want to create a macrovariable instead :
%let myDate=%sysfunc(putn(%sysfunc(today()),date9.));
%put &=myDate.;
Or
data _NULL_;
myDate=put(today(), date9.);
call symputx("myDate",myDate);
run;
You mix up several things :
- macro instructions/functions (beginning with %)
- base sas language, data step functions.
You can use a datastep function in a macro instruction with %sysfunc.
If you want to create a variable in a dataset with today's date :
data have;
myDate=put(today(), date9.);
put myDate=;
run;
If you want to create a macrovariable instead :
%let myDate=%sysfunc(putn(%sysfunc(today()),date9.));
%put &=myDate.;
Or
data _NULL_;
myDate=put(today(), date9.);
call symputx("myDate",myDate);
run;
data _null_;
date1=input(put(today(),yymmdd8.),yymmdd8.);
put date1;
format date1 date9.;
run;
Thanks the solutions:
%let myDate=%sysfunc(putn(%sysfunc(today()),date9.));
or
&sysdate9
work for me.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.