Hello Experts,
Do you know please a date format for this presetation of date : 20230213
Thank you !
@SASdevAnneMarie wrote:
Sorry, I did not specify, I would like to get it as macro variable.
You need to provide more detail. Attempting to do some mind reading, maybe this is what you're looking for:
%let current_date = %sysfunc(today(), yymmddn8.);
%put ¤t_date.;
YYMMDDN8.
@SASdevAnneMarie wrote:
Hello Experts,
Do you know please a date format for this presetation of date : 20230213
Thank you !
Sorry, I did not specify, I would like to get it as macro variable.
@SASdevAnneMarie wrote:
Sorry, I did not specify, I would like to get it as macro variable.
You need to provide more detail. Attempting to do some mind reading, maybe this is what you're looking for:
%let current_date = %sysfunc(today(), yymmddn8.);
%put ¤t_date.;
@SASdevAnneMarie wrote:
Sorry, I did not specify, I would like to get it as macro variable.
HOW do you expect to use that macro variable?
Quite often formatting a date into a value other than the native value is a poor choice as you can't use the text of a macro variable containing 20130213 to match the value of an actual date variable in a SAS data set.
A recent example of using a formatted macro variable date that fails because of the formatting: https://communities.sas.com/t5/SAS-Programming/Intck-does-not-give-the-desired-output/m-p/858470#M33...
@SASdevAnneMarie wrote:
Sorry, I did not specify, I would like to get it as macro variable.
Maxim 28: Macro variables should not be formatted. If you are going to perform arithmetic or Boolean logic on a macro variable, unformatted is best. The one exception: if you are going to use the macro variable in a label, title or filename, then it probably should be formatted.
You can use following format to get date in 20230213
yymmdd8.
Here is one simple example:
data _null_;
format dt yymmddn8.;
dt=today();
put dt=;
run;
output:
dt=20230213
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.