BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JuanEstebanBlan
Fluorite | Level 6

Hello community,

 

I have a program that worked very well in SAS Unniversity edition, but now in SAS onDemand for academics it no longer works.

 

I send some parameters to the macro and when the macro variables are concatenated to form the path of the file in some mysterious way a "//" is added to the path so the file cannot be found.

I show you the code and the error of the log.

 

Source

 

 

%macro import_emitidas_xls(rfc,anio,mes);

FILENAME REFFILE "/home/u58941115/cont/pmfecu/entradas/&rfc._Emitidas_&anio._&mes..xlsx";

PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=WORK.&rfc._Emitidas_&anio._&mes ;

GETNAMES=YES;
SHEET="XML";
RUN;

%mend import_emitidas_xls;

%let rfc= XBG1311088L6;
%let anio=2021;
%let mes= 01;

%import_emitidas_xls(&rfc,&anio,&mes);

 

Log

 

 

 

 ERROR: Physical file does not exist, /home/u58941115/cont/pmfecu/entradas//XBG1311088L6_Emitidas_2021_01.
 NOTE: The SAS System stopped processing this step because of errors.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Step 1 of macro development: start with working non-macro  code:

filename reffile "/home/u58941115/cont/pmfecu/entradas/XBG1311088L6_Emitidas_2021_01.xlsx";

proc import
  datafile=reffile
  dbms=xlsx
  out=WORK.XBG1311088L6_Emitidas_2021_01
  replace
;
getnames=yes;
sheet="XML";
run;

Once this works, proceed from there.

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

One slash is added, not two.

The code shown should not generate this error.

Please turn on option MPRINT and show us the full log report created by this code.

 

Kurt_Bremser
Super User

Step 1 of macro development: start with working non-macro  code:

filename reffile "/home/u58941115/cont/pmfecu/entradas/XBG1311088L6_Emitidas_2021_01.xlsx";

proc import
  datafile=reffile
  dbms=xlsx
  out=WORK.XBG1311088L6_Emitidas_2021_01
  replace
;
getnames=yes;
sheet="XML";
run;

Once this works, proceed from there.

JuanEstebanBlan
Fluorite | Level 6

You're absolutely right Kurt. The error is in the name of the physical file. The code had no problems. I got caught up in the LOG message and thought that by forming the filename with the macro variables I was adding a "/" in some strange way.

 

Thank you very much for your recommendation!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1600 views
  • 2 likes
  • 3 in conversation