DATA Step, Macro, Functions and more

Put statement problem

Reply
Contributor
Posts: 56

Put statement problem

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
Super Contributor
Super Contributor
Posts: 3,174

Re: Put statement problem

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
Contributor
Posts: 56

Re: Put statement problem

Thanks Scott, you idea works.
Ask a Question
Discussion stats
  • 2 replies
  • 134 views
  • 0 likes
  • 2 in conversation