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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.