SAS Component Language Dictionary |
Calculates simple statistics for SAS table columns
rc=VARSTAT(table-id,varlist-1,statistics,varlist-2);
|
-
rc
-
contains the return code for the operation:
0 |
successful |
0 |
not successful |
Type:
Numeric
-
table-id
-
is the identifier that was assigned when
the table was opened. If table-id is invalid,
the program halts.
Type: Numeric
-
varlist-1
-
specifies one or more numeric columns for
which to create the statistics.
Type: Character
-
statistics
-
specifies one or more statistics, separated
by blanks, from the table below. For more information about these statistics,
see the
SAS/STAT User's Guide.
Type:
Character
-
varlist-2
-
specifies one or more output variables to
contain the values produced by the specified statistics. The number of output
variables must equal the number of columns in varlist-1
multiplied by the number of statistics.
Note: These parameters are update parameters. See
Input, Output, and Update Parameters for more information. ![[cautionend]](../../../../common/62850/HTML/default/images/cautend.gif)
Type:
Numeric
Statistic |
Description |
CSS |
sum of squares of a column's values, corrected for the
mean |
CV |
coefficient of variation of a column's values |
KURTOSIS |
kurtosis of a column's values |
MAX |
largest value for a column |
MEAN |
mean of a nonmissing column's values |
MEDIAN |
median value for a column |
MIN |
smallest value for a column |
MODE |
value with the most rows for a column |
N |
number of rows on which calculations are based |
NMISS |
number of rows with missing values |
NUNIQUE |
number of rows having a unique value for a column |
RANGE |
range of values for a column |
SKEWNESS |
skewness of a column's values |
STD |
standard deviation of a column's values |
STDERR |
standard error of the mean |
SUM |
sum of nonmissing column values |
USS |
uncorrected sum of squares for a column |
VAR |
variance of a column's
values |
If more than one input column is specified
with more than one statistic, then each statistic is calculated on all columns
before the next statistic is calculated.
Calculate the maximum, mean, and minimum values for
the columns I and X from the table MY.NUMBERS:
tablename='my.numbers';
length imax xmax imean xmean xmin imin 8;
/* Declare the results as numeric. */
varname='i x';
numberid=open(tablename);
if (numberid=z0) then
do;
_msg_='Cannot open '||tablename;
return;
end;
statcode=varstat(numberid,varname,
'max mean min',imax,xmax,imean,xmean,imin,xmin);
put 'Column X';
put xmax= xmean= xmin=;
put 'Column I';
put imax= imean= imin=;
rc=close(numberid);
return;
LVARLEVEL
VARLEVEL
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.