DATA Step, Macro, Functions and more

How to change libname folder to current year

Accepted Solution Solved
Reply
Contributor
Posts: 37
Accepted Solution

How to change libname folder to current year

Hello,

 

We have a folder with year (folder2014, folder2015) and every new year, we have to modify the libname to read the current year. Is there a way to subsutiute the year with the %sysfunc(year("&sysdate"d));

 

LIBNAME '/SASLIBRARY/SASDATA/folder||&syear';

 

Thank you,

Bonnary


Accepted Solutions
Solution
‎12-21-2016 11:42 AM
Super User
Posts: 5,509

Re: How to change libname folder to current year

It shouldn't be a problem, but you will need to switch the double quotes and single quotes.  For example:

 

LIBNAME "/SASLIBRARY/SASDATA/folder%sysfunc(year('&sysdate'd))";

 

If it doesn't work as is, there should be an easy fix.  Give it a shot and see what you get.

 

View solution in original post


All Replies
Solution
‎12-21-2016 11:42 AM
Super User
Posts: 5,509

Re: How to change libname folder to current year

It shouldn't be a problem, but you will need to switch the double quotes and single quotes.  For example:

 

LIBNAME "/SASLIBRARY/SASDATA/folder%sysfunc(year('&sysdate'd))";

 

If it doesn't work as is, there should be an easy fix.  Give it a shot and see what you get.

 

Contributor
Posts: 37

Re: How to change libname folder to current year

Posted in reply to Astounding
Thank you, it's worked wonderfully.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 171 views
  • 1 like
  • 2 in conversation