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.

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 691 views
  • 0 likes
  • 2 in conversation