%macro countext (fileref=, dat=);
data file_ex;
keep filename;
length fref $8 filename $80;
rc = filename(fref, %nrstr("'&filref.'"));
if rc = 0 then
do;
did = dopen(fref);
rc = filename(fref);
end;
else do;
length msg $200.;
msg = sysmsg();
put msg=;
did = .;
end;
if did <=0 then putlog 'ERR' 'OR: Unable to open directory.';
dnum=dnum(did);
do i=1 to dnum;
filename=dread(did, i);
/* If this entry is a file, then output. */
fid=mopen(did, filename);
if fid>0 then output;
end;
rc=dclose(did);
run;
proc sql noprint;
create table file_ex1 as select *, scan(filename, 2, '. ') as ext from file_ex order by ext;
quit;
proc freq data=file_ex1 noprint;
tables ext/out=&dat.(drop=percent);
run;
%mend countext;
%countext (fileref=/home/abc/Test/new, dat=count_new);
This macro is used to find the count of files using file extension. I want resolve fileref path to files dataset.
Repeating:
Please run this command
options mprint;
and run your program again
SHOW US the LOG from running this macro (all of the LOG from this macro, 100%, every single character, do not chop parts out)
And what happens when you run this code? What is the problem that needs to be fixed?
Please run this command
options mprint;
and run your program again and SHOW US the LOG from running this macro (all of the LOG from this macro, 100%, every single character, do not chop parts out)
It is showing below message in log.
ERROR: Unable to open directory.
NOTE: Argument 1 to function DNUM(0) at line 40 column 40 is invalid.
ERROR: Invalid DO loop control information, either the INITIAL or TO expression is
missing or the BY expression is missing, zero, or invalid.
FREF= FILENAME= RC=0 DID=0 MSG= DNUM=. I=1 FID=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The
results of the operations have been set to missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 40:40
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FILE_EX may be incomplete. When this step was stopped
there were 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.01 seconds
Repeating:
Please run this command
options mprint;
and run your program again
SHOW US the LOG from running this macro (all of the LOG from this macro, 100%, every single character, do not chop parts out)
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: