Hi,
I am trying to import a txt file in a zip folder from a FTP. It is delimited by | . I am new to FTP and zip. I get an error that the directory or file doesn't exist.
Thanks!
filename rmt ftp 'myfile.zip' host='website.com'
user='user' pass='pass'
cd='directory' recfm=s debug;
FILENAME lcl 'folders/myfile.zip' recfm=n;
DATA _NULL_;
N=1;
INFILE rmt NBYTE=n;
INPUT;
FILE lcl ;
PUT _INFILE_ @@;
RUn;
Are you using SAS UE? If so, the path should be /folders/myfolders/...
filename rmt ftp 'myfile.zip' host='website.com' user='user' pass='pass' cd='directory' recfm=s debug; FILENAME lcl '/folders/myfolders/myfile.zip' recfm=n; DATA _NULL_; N=1; INFILE rmt NBYTE=n; INPUT; FILE lcl ; PUT _INFILE_ @@; RUn;
This just copies the files into your system. A nifty trick is to copy the file to your WORK folder, then when you end the session, the ZIP file is deleted as well. You would do that, as follows:
filename lcl "%sysfunc(getoption(work))/myfile.zip" recfm=n;
@hbh0810 wrote:
Hi,
I am trying to import a txt file in a zip folder from a FTP. It is delimited by | . I am new to FTP and zip. I get an error that the directory or file doesn't exist.
Thanks!
filename rmt ftp 'myfile.zip' host='website.com' user='user' pass='pass' cd='directory' recfm=s debug; FILENAME lcl 'folders/myfile.zip' recfm=n; DATA _NULL_; N=1; INFILE rmt NBYTE=n; INPUT; FILE lcl ; PUT _INFILE_ @@; RUn;
Hi,
Thank you for the replies! I am using SAS EG. For the filename lcl should that the be the location I want to copy the zip file? For instance, the zip file is on the FTP site, but I want to copy it to my personal drive? For me it is a little more complicated b/c I can't copy to my C:/ I have to copy to something that looks more like \\work.com\myfolder\ (I think b/c we have a server installation?). The log is below:
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTNAME='';
7 %LET _SASPROGRAMFILE=;
8
9 ODS _ALL_ CLOSE;
10 OPTIONS DEV=ACTIVEX;
11 GOPTIONS XPIXELS=0 YPIXELS=0;
12 FILENAME EGSR TEMP;
13 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
14 STYLE=HtmlBlue
15 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
16 NOGTITLE
17 NOGFOOTNOTE
18 GPATH=&sasworklocation
19 ENCODING=UTF8
20 options(rolap="on")
21 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
22
23 GOPTIONS ACCESSIBLE;
24
25 DATA _NULL_;
26 N=1;
27 INFILE rmt NBYTE=n;
28 INPUT;
29 FILE lcl ;
30 PUT _INFILE_ @@;
31 RUn;
NOTE: 220 Serv-U FTP Server v15.1 ready...
NOTE: <<< 220 Serv-U FTP Server v15.1 ready...
NOTE: >>> USER ****
NOTE: <<< 331 User name okay, need password.
NOTE: >>> PASS XXXXXXXXX
NOTE: <<< 230 User logged in, proceed.
NOTE: >>> OPTS UTF8 ON
NOTE: <<< 200 OPTS UTF8 is set to ON.
NOTE: >>> OPTS UTF8 NLST
NOTE: <<< 501 'NLST': 'UTF8' options not understood.
NOTE: >>> OPTS UTF-8 NLST
NOTE: <<< 501 'UTF-8 NLST': option not understood.
NOTE: >>> PORT 11,56,3,120,253,159
NOTE: <<< 200 PORT command successful.
NOTE: >>> TYPE I
NOTE: <<< 200 Type set to I.
NOTE: >>> CWD Home/number/sector/price/area
NOTE: <<< 550 / Home/number/sector/price/area: No such file or directory.
ERROR: Change Directory command for Home/number/sector/price/area failed.
ERROR: Directory or file Home/number/sector/price/area doesn't exist.
NOTE: UNBUFFERED is the default with RECFM=N.
NOTE: The file LCL is:
Filename=\\work.com\myfolder\price.zip,
RECFM=N,LRECL=256,File Size (bytes)=0,
Last Modified=07Feb2019:07:08:14,
Thanks again for helping this newbie!
Not sure if it will help but do you the correct case for the directory in the change directory? i.e. is it Home or home? or any of the other directories?
> The log is below:
1. The log incomplete and does not include the filename statements
2. The log is quite clear: Your filename statement points to a directory called Home/number/sector/price/area which does not exist.
I suspect you may have case issues and/or may be missing the initial slash or tilde.
You meant copy, not import. I was confused.
@Reeza 's suggestion should work. Please post the full log if it doesn't.
You'll have to use the ZIP engine to import the data once it's transferred.
filename MYZIP zip "&zipfile" member="dir/file.txt" ;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.