What is _n_?

Answer Posted / cutepa1

Almost all the above answers are right, except one or few.
Here I provide a clear insight into _n_ variable. This is an
automatic variable of PDV(Program Data Vector) that returns
the no. of observations that it has iterated. There are
such variables like _error_, end=, in=, first.by-variabke,
last.by-variable,etc.. All these variables will not be
displayed in the target output.
Ex:
data new;
set ora.emp;
if _n_ >= 2 and _n_ <= 6 then output;
run;
/* as _n_ returns 'n'th observation our statement is to save
those obs when _n_ returns the value between 2 and 6. Hence
the 5 obs of the specified dataset between second and six
are saved into 'new'.

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between nodup and nodupkey options?

628


what is broad cast agent? : Sas-bi

592


if a variable contain dates like "2015/01"---"2015/12" (yymm) ,How to add day to those dates,if them month is jan then 31 if the month is feb then 28 so on ...

936


Describe a time when you were really stuck on a problem and how you solved it?

2199


what are 5 ways to perform a table lookup in sas? : Sas-administrator

753






describe about physical data integration? : Sas-di

556


How we can call macros with in data step? : sas-macro

605


What is the basic structure of a sas program?

592


Explain how merging helps to combine data sets.

607


what is sas olap server? : Sas-di

681


What is by-group processing?

572


What are the advantages of using sas?

604


explain the key concept of sas? : Sas-administrator

554


How long can a macro variable be? A token? : sas-macro

712


Mention sas system options to debug sas macros.

657