Hello-
I have the following code and need to place a carriage return at a specific position in a text file. The start position of the carriage return/CRLF must be at 325. Can anyone help me?
DATA _NULL_;
file 'I:\ENCTv1.TXT' LRECL= 325;
IF _N_ = 1 THEN DO;
SET LEVEL_HDR;
PUT
@1 FILE_TYPE
@51 TOTAL_RECORDS_IN_FILE
@61 FILE_NAME
@86 FILE_ID
@118 FILE_RPT_PERIOD;
END;
SET LEVEL_body;
PUT @1 RECORD_NUM @11 ZIP @13 AGG_NUM @15 AGG_ID @49 TABLE_NAME @69 GRADE
@84 RESI @114 TOTAL_INDICATOR @315 COUNT;
RUN;
DATA _NULL_;
file 'I:\ENCTv1.TXT' LRECL= 325;
IF _N_ = 1 THEN DO;
SET LEVEL_HDR;
PUT
@1 FILE_TYPE
@51 TOTAL_RECORDS_IN_FILE
@61 FILE_NAME
@86 FILE_ID
@118 FILE_RPT_PERIOD;
END;
SET LEVEL_body;
PUT @1 RECORD_NUM @11 ZIP @13 AGG_NUM @15 AGG_ID @49 TABLE_NAME @69 GRADE
@84 RESI @114 TOTAL_INDICATOR @315 COUNT @325 '0D'x;
RUN;
Haikuo
Add the FILE statement option PAD.
Liked!
DATA _NULL_;
file 'I:\ENCTv1.TXT' LRECL= 325;
IF _N_ = 1 THEN DO;
SET LEVEL_HDR;
PUT
@1 FILE_TYPE
@51 TOTAL_RECORDS_IN_FILE
@61 FILE_NAME
@86 FILE_ID
@118 FILE_RPT_PERIOD;
END;
SET LEVEL_body;
PUT @1 RECORD_NUM @11 ZIP @13 AGG_NUM @15 AGG_ID @49 TABLE_NAME @69 GRADE
@84 RESI @114 TOTAL_INDICATOR @315 COUNT @325 '0D'x;
RUN;
Haikuo
Awesome! Placed the carriage return at 325- but now I have a blank row record after every data record??
Why not use :
file '~/exp.txt' dsd pad lrecl=75 termstr=CRLF;
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.