My date is date=20361;
I need my date format to be in YYYYMMDD format.
I tried to use this format YMMDDxw. format
Piece of code :-
data _null_;
tdy_date = put(date, yymmddn8.);
call symput('today_dt', tdy_date);
run;
data _null_;
file output_&today_dt.;
set output_ds;
run;
Then it'll depend on how you created your macro variable, but issues it the same, you're not passing the date to the function correctly.
tdy_date = put(&date, yymmddn8.);
It could be as simple as adding the & in front of your macro variable name.
Unless you have a variable date, this doesn't create anything, but since you don't have a SET statement, you don't have any variables.
tdy_date = put(date, yymmddn8.);
Were you intending to use TODAY() to return today's date?
tdy_date = put(today(), yymmddn8.);
@GunnerEP wrote:
My date is date=20361;
I need my date format to be in YYYYMMDD format.
I tried to use this format YMMDDxw. format
Piece of code :-
data _null_;
tdy_date = put(date, yymmddn8.);
call symput('today_dt', tdy_date);
run;
data _null_;
file output_&today_dt.;
set output_ds;
run;
Yes i do have a variable date passed from script. & its not today literally, the date is read from a file. So it can be date which is like 4 days back as well.
@GunnerEP Where is the date then? In another data set, in a macro variable? Maybe you need to add the SET statement to make the data available.
Then it'll depend on how you created your macro variable, but issues it the same, you're not passing the date to the function correctly.
tdy_date = put(&date, yymmddn8.);
It could be as simple as adding the & in front of your macro variable name.
data _null_;
tdy_date = put(date(), yymmddn8.); /* use the function date() here */
call symput('today_dt', tdy_date);
run;
data _null_;
file output_&today_dt.; /* do you have a fileref output_20180323 ? */
/* if not, you probably should use double quotes and a file extension */
set output_ds;
/* without a put statement, nothing will be written to the file */
run;
Don't force us to make guesses. Post your REAL code. And example data for the dataset from which you retrieve the date.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.