01-24-2013 09:33 AM
01-24-2013 09:43 AM
So, _N_ and _ERROR_ are automatically created but not 'kept" in the data step;
I don't think there are any 2 other variables created once _N_ initializes.
_N_ and _ERROR_ are the two variables created.
OK, I am talking in circles.
This reading should be helpful:
01-26-2013 09:52 AM
Somehow I think there is confusion about what the question is. At first you posted "When _n_ initializes, then which 2 variables it creates in the vector table."
Let me ease into this, first, by stating the fact that _N_ does NOT initialize anything.And, second, the Program Data Vector (PDV) is a memory area. It is NOT a "vector table". At an iteration of a DATA step program, the Program Data Vector holds one observation at a time. So, the correct term for this memory area is PDV or Program Data Vector, not "vector table".
I don't know how you got your question or who is asking the question or perhaps you got a bad translation of a question. In my reading of the postings in this thread, I think that your question might be better asked as something like this:
When a SAS DATA Step program creates the Program Data Vector (PDV), what 2 automatic variables are created?
In the Program Data Vector, what are the names and types of the 2 automatic variables that are created?
_N_ and _ERROR_ are the only 2 automatic variables created in the Program Data Vector (PDV). And, these 2 variables are only created when you use a DATA Step program. There is no Program Data Vector (PDV) created for SAS procedure steps.
In your last posting, you said that "_n_ and _error_ each creates 2 valriable in programme data vector... what is the name of that 2 variable n type of them" -- but from the very beginning, what you wrote was incorrect, so there is no way to answer the question that you asked.
_N_ and _ERROR_ do NOT create 2 variables each in the Program Data Vector. _N_ and _ERROR_ ARE the 2 variables created in the PDV.
When you write a DATA Step program, _N_ and _ERROR_ are created automatically in the Program Data Vector (PDV). These 2 automatic variables are both numeric variables. The values of these two variables will differ, because they each serve a different function. The documentation (from the site above), states EXACTLY what these 2 variables represent. The doc says that:
"The program data vector also contains two automatic variables, _N_ and _ERROR_. The _N_ variable counts the number of times the DATA step begins to iterate. The _ERROR_ variable signals the occurrence of an error caused by the data during execution. These automatic variables are not written to the output data set."
There is no ambiguity in the documentation. _N_ does not do the initializing and there are ONLY 2 automatic variables created in the PDV when you execute a DATA step program. The area of memory in which these automatic variables exist is called the Program Data Vector (PDV). The only thing that is not explicitly stated (but is implied) in that paragraph is that _N_ is numeric (because it is a counter variable) and _ERROR_ is also numeric in type.
There are other automatic variables that CAN be created in the PDV when you use syntax elements like BY or END= or IN=, however, you have to DO something to make the other automatic variables get created. Only _N_ and _ERROR_ are the variables that will be in the PDV just because you have written and executed a DATA Step program.
I hope this clarifies the answer to the question(s) that you did not ask.
01-26-2013 02:03 PM
Good point, Peter! I had not considered whether PROC IML might have _N_ and _ERROR_. I still question whether variables would ever initialize anything. Usually variables are being initialized.
However, the IML forum is here: https://communities.sas.com/community/support-communities/sas_iml_and_sas_iml_studio