I would like to assign a library with a macro variable when the pathname includes a numerical folder name.
I want to create a library with the following path;
libname wsale '/sasserver/my_unit/data/Wholesale/201810';I would like to derive 201810 from the user input which is
%let USER_MTH_END = '31OCT2018'd; How can I create 201810 and then pass it to the libname statement? I've tried many things but I can't get it to work without manually typing 201810 in the libname statement.
Thanks in advance
data _null_;
call symputx('period',put(&user_mth_end.,yymmn6.));
run;
libname wsale "/sasserver/my_unit/data/Wholesale/&period.";
data _null_;
call symputx('period',put(&user_mth_end.,yymmn6.));
run;
libname wsale "/sasserver/my_unit/data/Wholesale/&period.";
Without double quotes macro variables will not get resolved, they just remain as the string '&...'. The dot following the macro variable isn't technically needed in a lot of scenarios, it it there to tell the macro pre-processor that the macro variable name ends at the point, however in some circumtances it is really required, hence good practice is to always put the point at the end of the macro variable name - it will also highlight it as a macro variable in your code.
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.