BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

 

%macro import;
%do i=1 %to 6 ;
proc import datafile ="/home/u35263349/My_Folder/&csv_files&i..csv"
out=file_&i
dbms=csv
replace;
getnames=yes;
run;
%end;
%mend;
%import;

ERROR: Import unsuccessful. See SAS Log for details.

 

12 REPLIES 12
LinusH
Tourmaline | Level 20

Can you make it work outside the macrp?

Verify that the files exists and are accessible by the user that executes the program.

Do the headers comply with SAS naming conventions?

Make sure the file doesn't have garbage/special characters, or stored in a different encoding than your SAS session.

 

Data never sleeps
BrahmanandaRao
Lapis Lazuli | Level 10

I have take sample files 

japelin
Rhodochrosite | Level 12

Is "Titanic - 2.csv" being processed as "Titanic -2.csv"?
If so, I think the following will help you access it correctly.

%let csv_files=%str(Titanic - );
%macro import;
  %do i=1 %to 6 ;
    proc import datafile ="/home/u35263349/My_Folder/&csv_files&i..csv"
      out=file_&i
      dbms=csv
      replace;
      getnames=yes;
    run;
  %end;
%mend;
%import;

	

 

If you paste only the macro, we cannot determine if it is correct or not, so please paste the previous code, or at least the log, if possible.

 

BrahmanandaRao
Lapis Lazuli | Level 10

Anandkvn_0-1651832509999.png

 

PaigeMiller
Diamond | Level 26

 

 

When macros fail, you should turn on the macro debugging option by running the following command, and then run the macro again.

 

options mprint;

 

What you have shown us is not the log. This is a small portion of the log. Please show us the ENTIRE log, copied as text and pasted into the window that appears when you click on the </> icon.

2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png

--
Paige Miller
BrahmanandaRao
Lapis Lazuli | Level 10
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let csv_files=%str(shoes - );
 70         %macro import;
 71           %do i=1 %to 6 ;
 72             proc import datafile ="/home/u35263349/My_Folder/&csv_files&i..csv"
 73               out=file_&i
 74               dbms=csv
 75               replace;
 76               getnames=yes;
 77             run;
 78           %end;
 79         %mend;
 80         %import;
 MPRINT(IMPORT):   proc import datafile ="/home/u35263349/My_Folder/shoes - 1.csv" out=file_1 dbms=csv replace;
 MPRINT(IMPORT):   ADLM;
 MPRINT(IMPORT):   getnames=yes;
 MPRINT(IMPORT):   run;
 
 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, /home/u35263349/My_Folder/shoes - 1.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.00 seconds
       memory              8212.34k
       OS Memory           33560.00k
       Timestamp           05/06/2022 10:31:15 AM
       Step Count                        152  Switch Count  5
       Page Faults                       0
       Page Reclaims                     1088
       Page Swaps                        0
       Voluntary Context Switches        26
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 MPRINT(IMPORT):   ;
 
 
 MPRINT(IMPORT):   proc import datafile ="/home/u35263349/My_Folder/shoes - 2.csv" out=file_2 dbms=csv replace;
 MPRINT(IMPORT):   ADLM;
 MPRINT(IMPORT):   getnames=yes;
 MPRINT(IMPORT):   run;
 
 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, /home/u35263349/My_Folder/shoes - 2.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.01 seconds
       memory              8227.71k
       OS Memory           33560.00k
       Timestamp           05/06/2022 10:31:15 AM
       Step Count                        153  Switch Count  5
       Page Faults                       0
       Page Reclaims                     813
       Page Swaps                        0
       Voluntary Context Switches        25
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 MPRINT(IMPORT):   ;
 
 
 MPRINT(IMPORT):   proc import datafile ="/home/u35263349/My_Folder/shoes - 3.csv" out=file_3 dbms=csv replace;
 MPRINT(IMPORT):   ADLM;
 MPRINT(IMPORT):   getnames=yes;
 MPRINT(IMPORT):   run;
 
 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, /home/u35263349/My_Folder/shoes - 3.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.00 seconds
       memory              8226.28k
       OS Memory           33560.00k
       Timestamp           05/06/2022 10:31:15 AM
       Step Count                        154  Switch Count  5
       Page Faults                       0
       Page Reclaims                     777
       Page Swaps                        0
       Voluntary Context Switches        25
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 MPRINT(IMPORT):   ;
 
 
 MPRINT(IMPORT):   proc import datafile ="/home/u35263349/My_Folder/shoes - 4.csv" out=file_4 dbms=csv replace;
 MPRINT(IMPORT):   ADLM;
 MPRINT(IMPORT):   getnames=yes;
 MPRINT(IMPORT):   run;
 
 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, /home/u35263349/My_Folder/shoes - 4.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.00 seconds
       memory              8227.84k
       OS Memory           33560.00k
       Timestamp           05/06/2022 10:31:15 AM
       Step Count                        155  Switch Count  5
       Page Faults                       0
       Page Reclaims                     781
       Page Swaps                        0
       Voluntary Context Switches        25
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 MPRINT(IMPORT):   ;
 
 
 MPRINT(IMPORT):   proc import datafile ="/home/u35263349/My_Folder/shoes - 5.csv" out=file_5 dbms=csv replace;
 MPRINT(IMPORT):   ADLM;
 MPRINT(IMPORT):   getnames=yes;
 MPRINT(IMPORT):   run;
 
 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, /home/u35263349/My_Folder/shoes - 5.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.00 seconds
       memory              8226.15k
       OS Memory           33560.00k
       Timestamp           05/06/2022 10:31:15 AM
       Step Count                        156  Switch Count  5
       Page Faults                       0
       Page Reclaims                     777
       Page Swaps                        0
       Voluntary Context Switches        25
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 MPRINT(IMPORT):   ;
 
 
 MPRINT(IMPORT):   proc import datafile ="/home/u35263349/My_Folder/shoes - 6.csv" out=file_6 dbms=csv replace;
 MPRINT(IMPORT):   ADLM;
 MPRINT(IMPORT):   getnames=yes;
 MPRINT(IMPORT):   run;
 
 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, /home/u35263349/My_Folder/shoes - 6.csv. 
 ERROR: Import unsuccessful.  See SAS Log for details.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.01 seconds
       memory              8227.18k
       OS Memory           33560.00k
       Timestamp           05/06/2022 10:31:15 AM
       Step Count                        157  Switch Count  5
       Page Faults                       0
       Page Reclaims                     781
       Page Swaps                        0
       Voluntary Context Switches        25
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 MPRINT(IMPORT):   ;
 81         
 82         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         
PaigeMiller
Diamond | Level 26

You have to fix these ERRORs:

 

ERROR: Physical file does not exist, /home/u35263349/My_Folder/shoes - 2.csv. 
--
Paige Miller
BrahmanandaRao
Lapis Lazuli | Level 10

i have checked  sample shoes_1 file is available sucessfully imported this file could you please tell me my macro do loop code is correct or not

 

proc import datafile="/home/u35263349/My_Folder/csv_files/shoes_1.csv" out=ds
dbms=csv
replace ;
run;

Kurt_Bremser
Super User

@BrahmanandaRao wrote:

i have checked  sample shoes_1 file is available sucessfully imported this file could you please tell me my macro do loop code is correct or not

 

proc import datafile="/home/u35263349/My_Folder/csv_files/shoes_1.csv" out=ds
dbms=csv
replace ;
run;


This filename is radically different from what you stored in the macro variable(s).

PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:

i have checked  sample shoes_1 file is available sucessfully imported this file could you please tell me my macro do loop code is correct or not

 


But this name is not what your macro produces. Your macro has to produce this EXACT file name, not something that looks similar.

 

As stated earlier by @Kurt_Bremser , you need to create working SAS code without macros for the importing of one file before you can create a macro. If you don't have working SAS code, then your macro won't work either. 

 

So, please, show us working SAS code without macros for importing one file. That's the only way to make progress here.

--
Paige Miller
Tom
Super User Tom
Super User

So if that code works then this file exists:

"/home/u35263349/My_Folder/csv_files/shoes_1.csv" 

Where are the Titantic files you want to import?  Do they exist on that server also?

Kurt_Bremser
Super User

Never try to macrotize code before a single, non-dynamic instance works.

Make a single import for a single file work, then proceed from there.

The "physical file does not exist" is all you need to know and must be fixed.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 3767 views
  • 2 likes
  • 6 in conversation