BookmarkSubscribeRSS Feed
Mixer
Obsidian | Level 7

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.

24 REPLIES 24
Shmuel
Garnet | Level 18

In your log there is also next mesage:

 

WARNING: Apparent symbolic reference IMPORTFILENAME not resolved.

You use it in your FTP link:

 

 

ftp:\\usernameSmiley Tongueassword@server.com\folder\&importfilename

 

It should be predefined either by %LET statement or by %SYMPUT function or as a macro argument

 

Mixer
Obsidian | Level 7

Shmuel,

 

My password contains @. I am not sure if that cause the error. Thank you for your help!

Kurt_Bremser
Super User

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.

Mixer
Obsidian | Level 7

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!

Kurt_Bremser
Super User

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;
Kurt_Bremser
Super User

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.

Mixer
Obsidian | Level 7

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;

 

 

Shmuel
Garnet | Level 18

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.

Mixer
Obsidian | Level 7

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.

Kurt_Bremser
Super User

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.

Mixer
Obsidian | Level 7

@Kurt_Bremser @Shmuel 

 

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.

Tom
Super User Tom
Super User

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
;

 

Mixer
Obsidian | Level 7

@ 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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 24 replies
  • 3622 views
  • 0 likes
  • 4 in conversation