Help using Base SAS procedures

can someone educate me about variables _xxx_

Reply
Frequent Contributor
Posts: 89

can someone educate me about variables _xxx_

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?
Regular Contributor
Posts: 165

Re: can someone educate me about variables _xxx_

Posted in reply to littlestone
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!
SAS Super FREQ
Posts: 8,868

Re: can someone educate me about variables _xxx_

Posted in reply to littlestone
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
Trusted Advisor
Posts: 2,116

Re: can someone educate me about variables _xxx_

Posted in reply to Cynthia_sas
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
Frequent Contributor
Posts: 89

Re: can someone educate me about variables _xxx_

Thank you very much.
SAS Super FREQ
Posts: 8,868

Re: can someone educate me about variables _xxx_

Posted in reply to littlestone
Yes, sorry, I'd forgotten about that whole underscore issue. Hopefully, that will cease to be a problem in the future.

cynthia
Ask a Question
Discussion stats
  • 5 replies
  • 115 views
  • 0 likes
  • 4 in conversation