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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2836 views
  • 6 likes
  • 4 in conversation