I was reading the SAS code for calculating NBBO, and I came across the following code:
array nexb nexb:; array nexo nexo:; array sexb sexb:; array sexo sexo:;
I was wondering what does the statement array nexb nexb:;
do here?
Two things:
nexb:
is a variable list with a wildcard. It expands to the list of all variables on the PDV at that point in the data step that begin with nexb
. So the same as nexb1-nexb17
more than likely (without knowing what's in the datasets in the set
statement though). It's identical, and just used to make it easier to change that 17
sometime later without having to do so twice.
array nexb nexb:
creates an array, which is simply an organized variable list that allows you to say nexb[1]
instead of nexb1
, which is really more useful since [1]
can be [i]
or some other variable, while nexb1
cannot. So it allows you to go through a list of variables one at a time and use them or change them. The array does not exist in the dataset itself and is not persistent, it's just a shorthand way to refer to the variables.