DATA Step, Macro, Functions and more

Input statement

Reply
Contributor
Posts: 24

Input statement

Hi

This is a code from the Sas website:

data _null_;
infile file-specification-1;
file file-specification-2;
input;
put _infile_;
run;

What is _infile_ over here and what does it do? Is it an automatic variable like _all_?

Can someone please explain this data step?
Trusted Advisor
Posts: 2,115

Re: Input statement

It's easier to help if you cite where you found the code. That way we can comment in context.

Basically, the DATA step takes the data from file 1 and puts it into file 2. It is different from a simple OS copy in that it can do some rudimentary code translation for different environments (depending on the additional parameters specified in the INFILE and FILE statements).

The _INFILE_ automatic variable is documented with the INFILE statement,
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000146932.htm

The way I have most commonly used this is to create a hex print of the INFILE buffer when I am trying debug some messy data problem.

Doc Muhlbaier
Duke
Contributor
Posts: 24

Re: Input statement

Thanks! It was helpful.
Valued Guide
Posts: 765

Re: Input statement

hi ... in addition to the SAS documentation, you can learn a lot about uses of _INFILE_ by reading ...

first: "Now _INFILE_ is an Automatic Variable − So What?"
Howard Schreier

http://www.nesug.org/proceedings/nesug01/cc/cc4018bw.pdf

then try: "More _Infile_ Magic"
Peter Crawford

http://www2.sas.com/proceedings/sugi28/086-28.pdf
Ask a Question
Discussion stats
  • 3 replies
  • 142 views
  • 0 likes
  • 3 in conversation