1
votes

At the site I'm working at SAS runs on AIX while some of the files I need reside on window file servers. I have Googled several options but none have provided a solution/hope except this one:

enter code here
    filename indir 
    ftp 'Windows\Output\FO\20140813' 
    host=' xxxxxxx.xxxxxxxxxxxx.xxxxxxxxxxxx.xxx ' DIR
         user='xxxxxxxxx' pass=xxxxxxx;

    filename outdir 
    ftp '/AIX/Lev1/groups/xxx_xxx_xxxxxx/DPL' host=' xxxxxxx.xxxxxxx.xx DIR
    user='xxxxxxxxx' pass=xxxxxxx;

    data _null_;
       infile indir(DPL20140813.csv) truncover;
       input; 
       file outdir(DPL20140813.csv);
       put _infile_;
    run;

The problem that I run into is that only part of the first line is read and written containing the variable names and nothing else (of about 65,000 records).

What am I missing?

The log reads: NOTE: A total of 1 record was read from the infile library INDIR. The minimum record length was 256. The maximum record length was 256. NOTE: 1 record was read from the infile INDIR(DPL20140813.csv). The minimum record length was 256. 2 The SAS System 08:50 Monday, September 8, 2014

  The maximum record length was 256.

NOTE: A total of 1 record was written to the file library OUTDIR. The minimum record length was 256. The maximum record length was 256. NOTE: 1 record was written to the file OUTDIR(DPL20140813.csv). The minimum record length was 256. The maximum record length was 256. NOTE: DATA statement used (Total process time): real time 0.38 seconds cpu time 0.18 seconds

2

2 Answers

0
votes

I would guess it's a combination of TERMSTR and LRECL issue.

First, set LRECL to 32767 (max), or any particular value appropriate for your data. 256 is the standard, so it's probably got longer lines than 256 I'd guess.

Second, you need TERMSTR=CRLF, because AIX terminates only on LF. I'm not sure that this would cause your issue exactly, but it's certainly something you should be doing at least. This assumes the Windows file is created in windows (thus has CRLF on it).

0
votes

Instead of using SAS to read in and write out between two FTP locations, use SAS to simply invoke FTP on the command-line...

Example (not tested, substitute appropriate values accordingly) :

%LET WORK = %SYSFUNC(pathname(work)) ;
%LET REMOTE = remote.windows.com ;
%LET USER = ... ;
%LET PASS = ... ;
%LET LOCALDIR = ... ;
%LET REMOTEDIR = ... ;
%LET FILE = ... ;

data _null_ ;
  file "&WORK.ftp.txt" ;
  put "user &USER &PASS" ;
  put "lcd &LOCALDIR" ;
  put "cd &REMOTEDIR" ;
  put "get &FILE" ;
  put "close" ;
  put "bye" ;
run ;

%SYSEXEC ftp -n &REMOTE <&WORK.ftp.txt ;