Hi All,
I have to import numerous files into SAS on multiple times during the month. I would really like to automate this process, but to date have failed to do so. I have to work in a SAS EG 5.1 server environment, which it seems just gives dead-ends with everything I try. The code that I have at the moment follows below. Everything seels to work fine until I try to do the actual import. I have tried importing without using macros, which works fine, but that doesn't solve my problem The macro variable datafile="&FolderPath/&&File&i" resolves to the right values, but when I run the macro, I get the following error (I have tried using PIPE to import the files, but that also doesn't seem to work in the server environment):
Error
NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to
WORK.PARMS.PARMS.SLIST.
ERROR: Physical file does not exist, /sasdata/prototype/card_markerting_analytics/mart/ABMH684/CAMPAIGN
LEADS/PCUBED/Camp46_Apr2015/absa_cc_camp46_targetfile_ntf_absa_nvsc.txt.
ERROR: Import unsuccessful. See SAS Log for details.
SAS Code
Data List_files;
rc=FILENAME('FMyRep',"&FolderPath");
did=DOPEN('FMyRep');
memcnt=DNUM(did);
DO i=1 TO memcnt;
filevar=LOWCASE(DREAD(did,i));
IF LOWCASE(SCAN(filevar,-1,".")) EQ LOWCASE("&extension") THEN
OUTPUT;
END;
rc=DCLOSE(did);
rc=FILENAME('FMyRep');
KEEP filevar;
RUN;
DATA test;
set List_files;
where index(filevar,'absa_cc');
Count +1;
call symputx('File'||left(put(Count , 3.)), filevar, 'l' );
call symputx('Count', Count , 'l' );
run;
%put _user_;
proc sql;
select count(*) into: numfiles
from test;
quit;
%macro import();
%do i = 1 %to &numfiles;
proc import
datafile="&FolderPath/&&File&i"
out=_i
replace
dbms=dlm;
delimiter='|';
run;
%end;
%mend;
%import();
Any help solving this will be greatly appreciated!
The most likely cause of your error is that the directory and file you are trying to import is not accessible from your SAS server.
Where is /sasdata/prototype etc located? Is it on your SAS server or not? If you are not sure about this ask your SAS administrator.
BTW you can ignore the NOTE: Unable to open etc. That is a consequence of your SASUSER library being set to read-only, which is the default setup for SAS 9.4.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.