BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DataExplorer
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

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;

View solution in original post

4 REPLIES 4
gamotte
Rhodochrosite | Level 12

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;
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13
data _null_;
	date1=input(put(today(),yymmdd8.),yymmdd8.);
        put date1;
	format date1 date9.;
run;
Astounding
PROC Star
Yes, many errors. But the good news is that you don't need to do anything. There is an automatic macro variable that contains what you are trying to create: &sysdate9
DataExplorer
Fluorite | Level 6

Thanks the solutions:

 

%let myDate=%sysfunc(putn(%sysfunc(today()),date9.));

 or 

 

&sysdate9

 

work for me. Smiley Happy

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1926 views
  • 3 likes
  • 4 in conversation