Chapter Contents |
Previous |
Next |
VARLEVEL |
Category: | Variable |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
rc=VARLEVEL(array-name,n-level,table-id,var-name); |
0 | successful |
0 | not successful |
Type: Numeric
Type: Character
Note: This parameter is an update parameter. See Input, Output, and Update Parameters for more
information.
Type: Numeric
Type: Numeric
Type: Character
Details |
VARLEVEL fills the array array-name with the unique values of the SAS table column var-name.
This function returns values to the specified array. It also returns the total number of unique values in the n-level argument. Therefore, the second argument to this function cannot be a literal. If the number of unique values found exceeds the dimension of the array, the function returns only DIM(array-name) levels. That is, VARLEVEL requires the static allocation of an array that is big enough to hold all the unique values.
LVARLEVEL provides the same functionality, but it stores the unique values in an SCL list rather than an array. Because an SCL list can grow dynamically, you should consider using it rather than VARLEVEL.
Example |
Get the unique formatted values for the table column X. Use ASORT to sort those values in ascending order. If NLEVELS is greater than 25, then only the first 25 values are written to the array.
array values {25} $ 20; tableid=open('mylib.data','i'); nlevels=0; rc=varlevel(values,nlevels,tableid,'x'); rc=asort(values); do i=1 to dim(values); put values(i); end; rc=close(tableid);
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.