I am trying to assign the file name to the variable. I am getting error saying that symbolic variable names must be 32 or fewer character long. Which macro function I should be using so that I do not have to worry about the length of the file?
%let fname = my_file_name_is_xyz_20150202090056.txt;
data abc;
src_file_nm = symget("&fname.");
run;
Just get rid of SYMGET:
src_file_nm = "&fname.";
You are mixing styles. Symget will resolve the value in the data step variable.
&fname will resolve the value in place.
So either remove the & in symget(), or skip symget().
%let fname = my_file_name_is_xyz_20150202090056.txt;
data abc;
src_file_nm = symget("fname");
run;
You don't need & to refer a macro variable in symget(). Doing so will resolve first, then resolving outcome will become a macro variable name for symget to process. In this case the macro variable name is my_file_name_is_xyz_20150202090056.txt, which violates two rules of naming convention for SAS variable/macro variable: 1. The length <=32 char 2. only alphabetic and _ can be part of the name, here you have dot .
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.