BookmarkSubscribeRSS Feed
JatinRai
Obsidian | Level 7
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?
3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12
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
JatinRai
Obsidian | Level 7
Thanks! It was helpful.
MikeZdeb
Rhodochrosite | Level 12
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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 3 replies
  • 1711 views
  • 0 likes
  • 3 in conversation