Question

I want to get the file size of a csv file in AIX and using following X and Call System Command to do. The problem is I cant get the "File Size" in a macro variable which I will be using later in the program.

data _null_;
    call system('du -g p_bhj_c_hh100uk01po1.csv');
    call symput('space','X du -g p_bhj_c_hh100uk01po1.csv');
    %put &space; 
run;


WARNING: Apparent symbolic reference SPACE not resolved.
Was it helpful?

Solution

First, the SYMPUT subroutine you call does not work like you are trying to use it (ala Perl). I recommend reading the documentation on it.

The error you get on the SPACE macro is because it is inside the DATA Step. Macros "write" SAS code for you, so it &SPACE macro is trying to be resolved BEFORE the DATA Step executes.

Here is a code example to do what you are looking for:

data _null_;
rc = filename("ref","e:\temp\reg.pdf");
fid = fopen("ref");
infonum = foptnum(fid);
do i=1 to infonum;
    infoname = foptname(fid,i);
    infoval=finfo(fid,infoname);
    put infoname= infoval=;
end;
close = fclose(fid);
run;

/*In Windows, attribute is "File Size (bytes)"*/
data _null_;
rc = filename("ref","e:\temp\reg.pdf");
fid = fopen("ref");
size=finfo(fid,"File Size (bytes)");
call symput("size",size);
close = fclose(fid);
run;
%put &size;

The File Size attribute may be different in AIX. Run the first part to see all the attributes available. Then modify the second accordingly. Likewise, you will need to add the call to produce the file like you are already doing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top