Global Variables

 

WinCross provides the functionality to accumulate values between respondents using Global Variables.

 

Global variables can be used wherever WinCross logic is entered.

 

The syntax for defining/using a global variable is:

 

_GLOBAL_xxx (where "xxx" can be alpha and/or numeric characters)

 

For example:

 

_GLOBAL_TEST1

_GLOBAL_HIGHSCHOOL_GRADS

_GLOBAL_99

 

are all examples of the correct syntax for naming a global variable.

 

The example below from the Glossary of a WinCross job file shows you how to define every third male in your data file:

 

DECLARE SELECTED_MALES

IF GENDER (1) COMPUTE _GLOBAL_SELECTMALES = _GLOBAL_SELECTMALES + 1

IF _GLOBAL_SELECTMALES (3) ASSIGN SELECTED_MALES = (1)

IF _GLOBAL_SELECTMALES (3) ASSIGN _GLOBAL_SELECTMALES = (0)

 

_GLOBAL_SELECTMALES is the global variable and only gets accumulated if GENDER is equal to a code value of 1.

 

When the global variable _GLOBAL_SELECTMALES is equal to the value 3 (or every third male in the data file), the WinCross defined variable of SELECTED_MALES is assigned a code value of 1 and the global variable _GLOBAL_SELECTMALES is reset to 0.

Related topics:

Glossary Variables