 Dataplot Vol 2 Vol 1

# VALUE COUNT

Name:
VALUE COUNT (LET)
Type:
Let Subcommand
Purpose:
Compute the number of elements in a variable that are equal to a specified value.
Syntax:
LET <par> = VALUE COUNT <x1>
<SUBSET/EXCEPT/FOR qualification>
where <x1> is the variable for which the size is to be computed;
<par> is a parameter where the size is saved;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
LET XVALUE = 6
LET NVAL = VALUE COUNT Y
Note:
The value that is being checked is specified by entering the command

LET XVALUE = <value>

before entering the VALUE COUNT command.

Note:
Dataplot statistics can be used in a number of commands. For details, enter

Note that the VALUE COUNT statistic can also be computed using

LET VALCNT = SIZE Y SUBSET Y = VALUE

However, the VALUE COUNT command becomes more convenient when used with these various statistics. In particular, it is useful for obtaining counts with the various cross tabulation statistics. This is demonstrated in the Program 2 example below.

Default:
None
Synonyms:
None
Related Commands:
 SIZE = Compute the number of elements in a vector.
Applications:
Data Management
Implementation Date:
2014/04
Program 1:

let y = normal rand numb for i = 1 1 100
let y2 = y
let y2 =  3 subset y >  3
let y2 = -3 subset y < -3
.
let xvalue = 3
let nouth = value count y2
let xvalue = -3
let noutl = value count y2
.
set write decimals 3
print nouth noutl

The following output is generated.
 PARAMETERS AND CONSTANTS--

NOUTH   --          0.000
NOUTL   --          1.000

Program 2:
skip 25
let yout = y
let yout = -1 subset y < 0.2
let yout =  1 subset y > 0.4
.
set let cross tabulate collapse
let x1id  = cross tabulate group one   x1 x2
let x2id  = cross tabulate group two   x1 x2
let ycnt  = cross tabulate size x1 x2
let xvalue = -1
let ylow  = cross tabulate value count yout x1 x2
let xvalue =  1
let yhigh = cross tabulate value count yout x1 x2
.
set write decimals 0
print ycnt ylow yhigh x1id x2id

The following output is generated.
---------------------------------------------------------------------------
YCNT           YLOW          YHIGH           X1ID           X2ID
---------------------------------------------------------------------------
4              2              0              1              1
4              0              0              1              2
4              1              0              1              3
4              0              0              2              1
4              0              3              2              2
4              0              1              2              3
4              4              0              3              1
4              1              0              3              2
4              1              0              3              3


NIST is an agency of the U.S. Commerce Department.

Date created: 06/23/2014
Last updated: 06/23/2014