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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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