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;
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 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.