Quite often these sorts of If/then/else when using a single value to create or assign a new value to a different variable can be done with custom formats. Which moves such logic out of the data step.
If the repeated use of your new values starting with 01. 02. 03. etc is there for sort order purposes then a format, since it applies to the underlying value, would display in proper numeric value order (unless used in procedures that explicitly allow changing order to use formatted values).
Then running this code is not even needed.
Example of one format:
Proc format;
value op
-999999 = '01. Especial Value = -999999'
/* the -999999 below would likely better be the smallest
value you expect for the variable
*/
-999999 < - 17.00000 = '02. < 17.00000'
17.00000 - <20.00000 = '03. >= 17.00000 and < 20.00000'
20.00000 - high = '04. >= 20.00000'
;
run;
One example of use:
Proc print data=yourdatasetwithSystem ;
var system;
format system op. ;
run;
Formats have a great deal of flexibility that is not easy with if/then/else code. First the same format can be applied to multiple variables with a single statement:
format thisvar thatvar anothervar varlist1-varlist25 customformatname. ;
another is that formats can be stored between sessions in permanent libraries to be available when needed.
The formats can also be placed into data sets for sharing with the Proc Format Cntlin and Cntlout options.
Another feature might address what appears to be 2 missing "rows" in your example. You start with
/* row1 */ IF ( domain GE 21.00000 ) THEN name = '03. >= 21.00000';
But do not show, following the pattern for your other variables, what should be done with any DOMAIN with values less than 21, or "special" values.
The Proc format Value option "OTHER=" creates the value for any value not explicitly listed. Combined with the _error_ option it will also throw a log entry for any unexpected values encountered.
BTW, with this:
/* row6 */ IF ( region LT 2.00000 ) THEN LN = '01. < 2.00000'; ELSE
when Region has a missing value do you actually want a result of '01. <2.0000' ? That is what the code will do.
... View more