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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.