BookmarkSubscribeRSS Feed
littlestone
Fluorite | Level 6
I usually see in sas codes such variables _xxx_ as "_N_" "_INFILE_" "_Type_" and etc.

what are they? I have googled them but couldn't find a comprehensive introduction about such variables. can someone educate me about those variables?
5 REPLIES 5
RickM
Fluorite | Level 6
These are automatic variables. To find them in the doc you need to look under the statement that creates them (not that helpful if you don't know what created it). For _N_ look under SAS System Concepts/SAS Variables. For _INFILE_ look under the infile statement syntax. Try searching 'automatic variables' on lexjansen.com and see if there is a paper summarizing the most popular ones.

Good luck!
Cynthia_sas
SAS Super FREQ
Hi:
_N_ and _ERROR_ are automatic variables created for every DATA step program. _INFILE_ is created as an automatic variable that allows you to access an INPUT buffer.

Here's the doc:
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000695104.htm
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm

_TYPE_ could be created by a number of different procedures. For example, PROC MEANS creates an output dataset with _TYPE_ to indicate the combination of CLASS variables used to create a particular observation. Other procedures use _TYPE_. You will have to look in the doc for the procedure that created _TYPE_ to find out about that.

BY group processing creates a different type of automatic variable, for example. If you have this statement in a program:
[pre]
data myclass;
set sashelp.class; by age;
...more code...
run;
[/pre]

Then you can use the automatic variables FIRST.AGE and LAST.AGE to detect the beginning and ending observations in a group.

Usually, if you search on the support.sas.com site, you can limit your search to the SAS documentation and this will help you zero in on the doc for the feature, option, etc that you are looking for -- it is more concentrated than a Google search -- and for documentation, generally more effective.

cynthia
Doc_Duke
Rhodochrosite | Level 12
Cynthia,

Littlestone's challenge was not Google, it was the underscores. Both Google and the SAS search engine ignore them (try searching for _N_ on the SAS site to experience the futility).

Doc
littlestone
Fluorite | Level 6
Thank you very much.
Cynthia_sas
SAS Super FREQ
Yes, sorry, I'd forgotten about that whole underscore issue. Hopefully, that will cease to be a problem in the future.

cynthia

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 687 views
  • 0 likes
  • 4 in conversation