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

Hello guys,

 I need use a value of macro variable as a part of the filename path in file name statement for dynamic environment. But when I tried the below code macro variable 'src' not resolved so am not getting expected result.

Can any one help to overcome this??

data Temp1;
	set Temp;
	start_time1=datepart(start_time);
	call symput('Newdate',start_time1);
	call symput('src',ZP_FL_NM);
run;

%let filrf=myfile;

%let rc=%sysfunc(filename(filrf,
	"/D:/Folder/src"));

%let fid=%sysfunc(fopen(&filrf));
%let Bytes=%sysfunc(finfo(&fid,File Size (bytes)));
%let Fname=%sysfunc(finfo(&fid,Filename));
%let fidc=%sysfunc(fclose(&fid));
%put &Bytes &Fname;
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I am guessing you need:

%let rc=%sysfunc(filename(filrf,
	"/D:/Folder/&src."));

Or something along those lines.  But why have the macro code using macro variables created from a datastep?  Just use the datastep to open the file and get number of bytes, i.e. all but about two lines are totally unecessary:
 

data temp;
fid=fopen(); bytes=finfo(fid,File Size (bytes)); Fname=finfo(fid,Filename); fidc=fclose(fid);
run;

And have a call symput if you need to at the end.

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You have created the macro variable &src, and then you never use this macro variable anywhere. Perhaps that is the problem?

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I am guessing you need:

%let rc=%sysfunc(filename(filrf,
	"/D:/Folder/&src."));

Or something along those lines.  But why have the macro code using macro variables created from a datastep?  Just use the datastep to open the file and get number of bytes, i.e. all but about two lines are totally unecessary:
 

data temp;
fid=fopen(); bytes=finfo(fid,File Size (bytes)); Fname=finfo(fid,Filename); fidc=fclose(fid);
run;

And have a call symput if you need to at the end.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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