Interview Questions   Tutorials   Discussions   Programs   Videos   

SAS - What is _n_?

asked mar September 20, 2014 06:30 AM  

What is _n_?


1 Answers

answered By vishnoiprem   0  

Automatic Variables Automatic variables are created automatically by the DATA step or by DATA step statements. These variables are added to the program data vector but are not output to the data set being created. The values of automatic variables are retained from one iteration of the DATA step to the next, rather than set to missing.

Automatic variables that are created by specific statements are documented with those statements. For examples, see the BY statement, the MODIFY statement, and the WINDOW statement in SAS Language Reference: Dictionary. Two automatic variables are created by every DATA step: N and ERROR. N is initially set to 1. Each time the DATA step loops past the DATA statement, the variable N increments by 1. The value of N represents the number of times the DATA step has iterated.

ERROR is 0 by default but is set to 1 whenever an error is encountered, such as an input data error, a conversion error, or a math error, as in division by 0 or a floating point overflow. You can use the value of this variable to help locate errors in data records and to print an error message to the SAS log.

For example, either of the two following statements writes to the SAS log, during each iteration of the DATA step, the contents of an input record in which an input error is encountered:

if error=1 then put infile;

if error then put infile;

   add comment

Your answer

Join with account you already have



 Write A Tutorials
Online-Classroom Classes

  1 person following this question

  Question tags

sas × 1

Asked 2 years and 3 months ago ago
Number of Views -564
Number of Answers -1
Last updated
3 years and 2 months ago ago

  Similar questions

Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!