BookmarkSubscribeRSS Feed
Mince
Calcite | Level 5

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!

2 REPLIES 2
Reeza
Super User
Do all the files have the same format? Is it okay if they are imported to the same dataset?

In your current code the _i that should be what? It isn't a macro variable, but should be? You use i, not _i in your loop though.
SASKiwi
PROC Star

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 914 views
  • 0 likes
  • 3 in conversation