Hello,
I have a hard cord FTP link in my script, similar to below.
ftp:\\username:password@server.com\folder\&importfilename
I received this error at the very end and I am not sure why.
ERROR: A component of
C:\Users\sassupport\AppData\Local\Temp\ftp:\\username:password@server.com\folder\&importfilename.
is not a directory.
Why do I receive this error? I have attached the bottom portion of the log in this message.
Thank you for your inputs.
In your log there is also next mesage:
WARNING: Apparent symbolic reference IMPORTFILENAME not resolved.
You use it in your FTP link:
ftp:\\usernameassword@server.com\folder\&importfilename
It should be predefined either by %LET statement or by %SYMPUT function or as a macro argument
Shmuel,
My password contains @. I am not sure if that cause the error. Thank you for your help!
The statement(s) that cause(s) the error are further up in the log, part of a previous macro call.
I guess you are trying to use a URI in a place where only a simple file name is expected, so the ftp:// is not recognized as what it is.
Mind that SAS has a dedicated mechanism to access FTP sites, namely filename ftp.
Hi Kurt,
I have attached full log in this message, would you please take a look at it for me? Thank you very much for your help!
You cannot use a ftp:// style URI in a simple filename. Instead use the FILENAME, FTP Access Method.
You find that in lines 541 and 542 of your log.
You also have a problem with the SQL in lines 510 to 515. Mind that _n_ is a data step variable and not present in proc sql selects, so the where condition is never true.
Do this instead:
data _null_;
set Filenames_parse (obs=1);
string = trim(left(tranwrd("&tablename.",'_','-')||'-'||substr(put(dateinfo,8.0),1,4)||'-'||substr(put(dateinfo,8.0),5,2)||'-'||su
bstr(put(dateinfo,8.0),7,2)))||'.csv';
call symput('importfilename',string);
run;
If you get problems with the PORT subcommand, use the PASSIVE option in the filename ftp statement.
Standard FTP protocol turns the client into a server that listens (when eg the GET command is issued), and sends the port to the FTP server, which then opens the connection from its side. When firewalls are involved, that usually fails. PASSIVE means that all connections are initiated by the client to ports that the server listens on.
Hi Kurt,
I used the passive option and I did not the error anymore. But I got "Statement is not valid or it is used out of proper order." error and I think that has to do with the text in bold. I am not sure what is wrong with it.
Sorry, I am very new to SAS and I just inherited this. I am trying to make this work so please be patient with me. I really appreciate of all your help so far. Thank you.
filename c ftp 'translate_temp.csv' cd='Ampthink/' PASSIVE
user='ud4b2'
pass="M@amP"
host='sharefileftp.com'
recfm=v prompt;
data WORK.retention ;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile c delimiter=',' MISSOVER DSD lrecl=32767 firstobs=2;
&informatstring
&formatstring
input &typestring;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable*/
run;
I guess you need to put semicolons after each of the first two macro variables.
Change 2nd step to:
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
data WORK.retention ;
infile c delimiter=',' MISSOVER DSD lrecl=32767 firstobs=2;
&informatstring;
&formatstring;
input &typestring;
if _ERROR_ then
call symputx('_EFIERR_',1); /* set ERROR detection macro variable*/
run;
In case of any error please post the log.
Hi All,
I still get the same error and "Expecting a name." error. I have attached the log in this message.
Thank you for your help again.
You are using macro variables that have not been set. The "expecting a name" is the consequence of this.
See this part of the log:
38 input &typestring; _ 22 WARNING: Apparent symbolic reference TYPESTRING not resolved. ERROR 180-322: Statement is not valid or it is used out of proper order. ERROR 22-322: Expecting a name.
&typestring has not been set, causing the WARNING. It's a WARNING and not an ERROR because sometimes you want to use a string that looks like a macro variable call, but isn't.
Since SAS expects a variable name as the next argument to the input statement, and the string (now it is used as such) &typestring is not a valid SAS name, you get the ERROR.
This also illustrates the importance of posting the complete log of a failed step. SAS padawans often only see the last ERROR of a sequence of messages, where in fact the previous messages point to the real cause.
I tried to use the PASSIVE option and not I got this error.
"ERROR: Invalid Reply received for the PASV command.."
My syntax is as below, Is that the right place the PASSIVE option?
filename a ftp '&importfilename.' cd='Ampthink/' PASSIVE
user='xxxxxx
pass="xxxxxx"
host='orlandomagic.sharefileftp.com'
recfm=v prompt;
Thank you for your help again.
Mixer wrote:...
filename a ftp '&importfilename.' cd='Ampthink/' PASSIVE
user='xxxxxx
pass="xxxxxx"
host='orlandomagic.sharefileftp.com'
recfm=v prompt;
Thank you for your help again.
Macro variable references will not resolve inside of single quotes. So your FTP command is looking for a file whose name is literally &importfilename. Also make sure to match your quotes.
filename a ftp "&importfilename." cd='Ampthink/' PASSIVE
user='xxxxxx'
pass="xxxxxx"
host='orlandomagic.sharefileftp.com'
recfm=v prompt
;
@ Tom
Thank you for your input. I was able to resolve the issue for some places. But I still get the error for below codes.
"Invalid Reply received for the PASV command.."
%macro get_filenames(location);
filename _dir_ "%bquote(&location.)";
data filenames(keep=memname);
handle=dopen( '_dir_' );
if handle > 0 then do;
count=dnum(handle);
do i=1 to count;
memname=dread(handle,i);
output filenames;
end;
end;
rc=dclose(handle);
run;
filename _dir_ clear;
%mend;
*%get_filenames(\\192.168.103.2\tm\live_analytics);
*%get_filenames(\\192.168.103.4\ftp\Ampthink);
filename ftpdir ftp 'Ampthink/' ls PASSIVE
user='xxxxxxxxxxxx'
pass='Mxxxxxxxx'
host='orlandomagic.sharefileftp.com'
prompt;
%get_filenames("ftpdir");
I wrap that ftpdir variable with double quotes and past it to get_locations macro but it does not work. Would you please take a look and let me know what's wrong with it?
Thank you for your help again.
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: