08-27-2015 05:14 PM
I would like to create a long series of indicator variables based on a set of criteria. The code I am using looks like this:
The basic idea is to create ind1 to ind99 based on whether tenure is greater than or equal to the test counter and whether the levels of risk and value are low. Running this, I seem to be getting 0s for the indicator variables created, even when the values for a particular record meet the criteria.
As a secondary matter, I would like to ideally generalize this because I two other value levels for risk (medium and high) and 4 other value levels for value. My approach now is to create other sets of array variables for the other combinations of risk and value. But I suspect there is a better way. Would a multidimensional array help here?
08-27-2015 05:43 PM
Why do you need all these indicator variables?
At any rate, why loop through it all? Set the array default to and only start setting to 1 when tenure=test for starters.
Second, you can use do loops to loop over character values.
do value="low", "medium", "high";
09-08-2015 11:33 AM
As written your loop
do test=1 to 10 by 0.1;
ind = (tenure >= test and risk="low" and value="low");
1) does not properly reference the array, to refernce an element of the array you want something like: ind[i] = (<code goes here>);
2) is only ever going to yield the result for test= 10