What is _n_?

Answers were Sorted based on User's Feedback



What is _n_?..

Answer / sru

The value of _N_ represents the number of times the DATA
step has iterated

Is This Answer Correct ?    23 Yes 2 No

What is _n_?..

Answer / raghu

This is a data counter variable used in SAS.

..Raghu

Is This Answer Correct ?    14 Yes 3 No

What is _n_?..

Answer / ravi

This is nothing but a implict variable created by SAS during
data processing. It gives the total number of records SAS
has iterated in a dataset. It is Available only for data
step and not for procs.

Eg. If we want to find every third record in a Dataset then
we can use the _n_ as follows
Data new-sas-data-set;
Set old;
if mod(_n_,3)= 1 then;
run;
Note: If we use a where clause to subset the _n_ will not
yield the required result.

Is This Answer Correct ?    13 Yes 3 No

What is _n_?..

Answer / 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

What is _n_?..

Answer / hymad

this option is used to pick up n number of observation from
particular dataset

Is This Answer Correct ?    7 Yes 3 No

What is _n_?..

Answer / vijaibhaskar

_ n_ give no.of times data step is itereated .it gives
correct observations nos only if IF SUBSET IS NOT USED in
the datastep

Is This Answer Correct ?    4 Yes 0 No

What is _n_?..

Answer / madhavi

_n_ is a automatic variable created by SAS.we can use this
like we use any variable that we created ourselfs and it
indicates the number of times SAS has looped through the
data step.

Is This Answer Correct ?    4 Yes 0 No

What is _n_?..

Answer / arun

IT IS AUTOMATIC VARIABLE SHOWS NUMBER OF ITERATIONS.

Is This Answer Correct ?    4 Yes 1 No

What is _n_?..

Answer / suresh b anisetty

_n_ is a automatic variable the function of _n_ is how many
times the data step begins to execute.

Is This Answer Correct ?    3 Yes 1 No

What is _n_?..

Answer / yuva

its an automatic variable.it shows no. of iterations gone
through in datastep

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More SAS Interview Questions

I have a SCD Type 2 Dimention for Location In which A Sales Office in Having two Surrogate Keys just because of the change in it's Sales Group. SKey SalesGroup Sales Office BeginDate EndDate 280 SG1 SO1 01APR2000 01APR2010 281 SG2 SO1 02APR2010 31MAR2999 Now while loading the Fact, the Lookup ir returning SKey 280 for records before and after 01APR2010. I am not able to give WHERE condition in the Lookup Properties (TranDate between BeginDate and EndDate). Please help.

0 Answers  


How would you delete observations with duplicate keys?

6 Answers  


Mention few capabilities of sas framework.

0 Answers  


what is pdv? how it is related to input buffer in sas?

5 Answers   HSBC, Satyam,


how to remove the duplicates by proc sql?

2 Answers   Genpact,






Explain proc univariate?

0 Answers  


/* To determine the maximum and minimum of V1 */ data before3; input v1 v2 v3; cards; 3 2 1 4 6 5 2 1 3 6 5 4 1 3 2 5 4 6 ; run;

5 Answers  


Briefly describe 5 ways to do a "table lookup" in sas.

4 Answers   Quintiles,


what is treatment emergent events and treatment emregent adverse event

0 Answers  


How would you create multiple observations from a single observation?

1 Answers   Quintiles,


The below code we are using for creating more than one macro variables in proc sql using into clause. How we can use same code to create macro variables vara, varb, varc instead of var1, var2, var3.? proc sql noprint; select count(distinct(patient)) into :var1 - :var3 from dataset1 group by trtreg1c ; quit;

1 Answers   Accenture,


What is the maximum and minimum length of macro variable

0 Answers  


Categories