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