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

here i am trying to copy a .txt file from one server to another  ftp server.But when I copy the file, I am getting the records in each  new line.But i want the records to be in the same line upto the line size of 1024 as they were in the original file.
I have attached the original(before_copy.txt) and copied file(after_copy.txt),which is same before_copy.txt after getting copied to ftp site.I have renamed it for your reference.

the code which i have used to copy the file is as follows:-

filename indir '/Shared/ABC/';
  
filename outdir ftp dir host='****'
         user='***' pass="***" ;

data _null_;

   infile indir(before_copy.txt)  lrecl=1024 ;
   input;
   file outdir(before_copy.txt)  lrecl=1024 ;
   put _infile_;
run;

Kinly let me know which option i need to use to copy the file as it was in the original one.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The files look to be in UNIX format (no CR/LF, only LF as line separator). But before_copy has 2 '0D'x characters, which are considered unwanted artifacts in UNIX text files and get stripped out by the FTP engine(s), most probably not SAS. You also have one empty line (2 '0A'x in succession) where SAS probably skips the line (missover default option).

Bottom line: if you need an _exact_ copy, use command line ftp/sftp and specify binary mode.

Or try the recfm=n option in SAS.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

The files look to be in UNIX format (no CR/LF, only LF as line separator). But before_copy has 2 '0D'x characters, which are considered unwanted artifacts in UNIX text files and get stripped out by the FTP engine(s), most probably not SAS. You also have one empty line (2 '0A'x in succession) where SAS probably skips the line (missover default option).

Bottom line: if you need an _exact_ copy, use command line ftp/sftp and specify binary mode.

Or try the recfm=n option in SAS.

sas_lak
Quartz | Level 8

Hi from sas we can COPY, PASTE, CUT and DELETE the raw datafiles using X - Statement

Ex:-  X 'COPY "Path exist folder\test.txt" "Defined folder\out.txt"';

         X MOVE "Path exist folder\test.txt" "Defined folder\out.txt"';

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 2918 views
  • 6 likes
  • 4 in conversation