Seppo Mustonen : Programming Survo in C

Functions in library SURVO.LIB

scale_ok
Summary

int scale_ok(data,i,scale)
SURVO_DATA *data; /* pointer to data structure */
int i;            /* # of variable */
char *scale; /* list of allowed scales as a string */
Description

The scale_ok function tests whether the scale type of variable # i in data opened by data_open or data_open2 belongs to the given list scale of scale types. In survodat.h the following scale types are predefined:

#define ORDINAL_SCALE       " DOoSsIiRrF"
#define SCORE_SCALE         " DSsIiRrF"
#define INTERVAL_SCALE      " DIiRrF"
#define RATIO_SCALE         " RrF"
#define DISCRETE_VARIABLE   " DNOSIRF"
#define CONTINUOUS_VARIABLE " osir"
where the different scale types are denoted as follows:
    -  no scale
       (blank)    scale unknown
    D  Dichotomy  (two distinct numeric values)
    N  Nominal
    O  Ordinal    (discrete)
    o  Ordinal    (continuous)
    S  Score      (discrete)
    s  Score      (continuous)
    I  Interval   (discrete)
    i  Interval   (continuous)
    R  Ratio      (discrete)
    r  Ratio      (continuous)
    F  Frequency
Return Value

scale_ok returns 1 if the scale of variable # i is found in scale. Otherwise 0 is returned. If the system parameter scale_check is 0, then scale is not checked at all and 1 is returned. However, if the scale of variable # i is '-', 0 is returned irrespective of scale and the value of scale_check.

See Also

scales

Example

int i;
int weight_variable;
SURVO_DATA dat;

i=data_open("TEST",&dat);
if (i<0) return;
weight_variable=activated(&dat,'W');
if (weight_variable>=0)
 {
 if (!scale_ok(&dat,weight_variable,RATIO_SCALE))
   {
   sprintf(sbuf, "\nWeight variable %.8s must have ratio scale!",
               dat.varname[weight_variable]);
   sur_print(sbuf); WAIT;
   if (scale_check==SCALE_INTERRUPT) return;
   }
 }


Front page of Survo C libraries