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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

10 REPLIES 10
Reeza
Super User

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;


 

GunnerEP
Obsidian | Level 7

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.

Reeza
Super User

@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.

 

GunnerEP
Obsidian | Level 7
Yes macro variable.
Reeza
Super User

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.

GunnerEP
Obsidian | Level 7
Thanks! Yes i missed the & in deed! 😞
Kurt_Bremser
Super User
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;
GunnerEP
Obsidian | Level 7
Hi Kurt,

Date is retrieved from a macro variable. To determine the tdy_date.

I do have a file ref, i am getting my output its just that the date variable is not getting resolved in the file name.
& i have put statement as well.( apologies missed out when i copied it here).
GunnerEP
Obsidian | Level 7
Will keep this in mind from next time. Thanks for your response. Good Day!

SAS Innovate 2025: Register Now

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!

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
  • 10 replies
  • 58800 views
  • 0 likes
  • 3 in conversation