BookmarkSubscribeRSS Feed
pp2014
Fluorite | Level 6

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;

3 REPLIES 3
Astounding
PROC Star

Just get rid of SYMGET:

src_file_nm = "&fname.";

LinusH
Tourmaline | Level 20

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().

Data never sleeps
Haikuo
Onyx | Level 15

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1528 views
  • 0 likes
  • 4 in conversation