*! version SWS3/stb-2:gr3/stb-12:gr3.1 gr3 utility program define _3dmnmx version 2.1 quietly { sum %_1 mac def _diff = _result(6) - _result(5) if %_diff==0 { mac def _diff 1 } gen _NEW=(%_1-_result(5))/(%_diff) mac def %_2`ZERO=-(_result(5)/(%_diff)) drop %_1 rename _NEW %_1 } end exit /* _3dmnmx varname key rescales varname to have range [0,1]. creates a macro named keyZERO that contains the value of the rescaling corresponding to zero. Note: varname is recreated rather than replaced. If varname was stored as an int and we simply replaced, we would end up with all zeros and a single 1. This way, we get what we want. */