BookmarkSubscribeRSS Feed
Kwok
Calcite | Level 5
I try to do a quick and dirty extract of portions from a huge flat file and write out to
another file with the same position using the following code.

DATA ONE;
INFILE INF TRUNCOVER;
INPUT VAR1 $ 127-165
VAR2 $ 265-434
VAR3 $ 457-507
VAR4 $ 527-597
VAR5 $ 660-860
VAR6 $ 861-1060
VAR7 $ 1061-1207
;
RUN;

DATA _NULL_ ;
SET ONE;
FILE OUTC ;
PUT VAR1 127-165
VAR2 265-434
VAR3 457-507
VAR4 527-597
VAR5 660-860
VAR6 861-1060
VAR7 1061-1207
;
RUN;

However, there is nothing in the output file. Can anyone offer some tips why this is not writing out and how to resolve this porblem, ?

Thanks
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Likely your SAS log reveals warnings, possibly error msgs, related to what you are seeing (or not in this case).

Suggest you simplify your SAS program - there is no need for two DATA steps, also you can use a PUT _INFILE_; statement, coded after your INPUT statement in your first DATA step -- eliminating the need for any additional code. And your first DATA step can specify _NULL_ instead of a SAS dataset since you are reading and writing the external file without needing to create a SAS file. Also, if you are not intending to re-format the file, then the INPUT statement can be simplified to INPUT ; (no SAS variables input).

Confirm some information though, such as what OS platform where the external file resides?

And if you must re-post a reply, provide your exact SAS log output (with COPY and PASTE) while revealing all SAS code and SAS-generated messages.

Scott Barry
SBBWorks, Inc. Message was edited by: sbb
Kwok
Calcite | Level 5
Thanks Scott, you idea works.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1300 views
  • 0 likes
  • 2 in conversation