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;
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.
You have created the macro variable &src, and then you never use this macro variable anywhere. Perhaps that is the problem?
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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.