Feature Upgrade: Starting with CSPro 7.3, you should no longer use this function as it may soon be removed from CSPro. To replicate the behavior of the function, you can use the setvalueset function with dynamic value sets.
i = setvalueset(item_name, codes_array, labels_arrayʃ, images_arrayʅ);
The
setvalueset function allows you to dynamically change an item's current value set. An item's current value set is used to determine whether or not entered values are out of range. The current value set is also used to provide the value choices displayed in
capture types. The changing of a value set is not permanent; it remains in effect only during the processing of the current case or until the next call to
setvalueset.
The item_name is the name of the item in the data dictionary whose value set is to be changed. The second argument, codes_array, is an array of codes to use in the new value set and the third argument, labels_array, is an array of labels that correspond to the values in the codes array (the nth element of the labels array is the label for the nth element in the codes array). If the item is numeric, codes_array must be a numeric array. If the item is alphanumeric, codes_array must be a string array. The labels_array must always be a string array. The optional fourth argument, images_array, is a string array pointing to image filenames to be used as value set images.
When working with the
codes_array, to indicate the end of a numeric array, assign the special value
notappl to the position after the last valid code. To indicate the end of a string array, assign a blank value. This indicates when to stop loading values from the array.
In versions of CSPro earlier than 6.0, the value set labels and codes array needed to start at index position 0. Zero-based arrays are still permitted, but if a one-based array is passed to the function (and the zeroth element has never been assigned to), then CSPro will start processing the dynamic value set at array position 1.
The function returns the number of codes in the newly created value set.
PROC GLOBAL
array vsCodes(100);
array string vsLabels(100);
PROC DISTRICT
preproc
vsCodes(1) = 1;
vsLabels(1) = "District 1";
vsCodes(2) = 2;
vsLabels(2) = "District 2";
vsCodes(3) = 3;
vsLabels(3) = "District 3";
vsCodes(4) = notappl; // mark the end of the array
setvalueset(DISTRICT, vsCodes, vsLabels);