As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

# Numeric transformations/Code

Here is the code used to generate the tables presented in Numeric transformations.

```data values;
do value = . , .m , -43.2 , -1  , 0 , 1 , 23.4; output; end;
run;

data value_x_formula;
set values;
monotone + 1;
_label_ = ifc( value=.M,'.M',put(value,best5.-L) );
negation = - value;
abs = abs(value);
miss2zero = sum(value,0);
sign = sign(value);
missing = missing(value);
divisor = value ne 0;
not = not value;
boolean = not not value;
positive    =   sign(value) EQ       1;
nonnegative =   sign(value) IN (   0,1);
negative    =   sign(value) EQ  -1     ;
nonpositive =   sign(value) IN (-1,0)  ;
_3b_not = 1 - abs( sign(value) );
_3b_boolean = abs( sign(value) );
_3b_positive    =  1 + sign( sign(value) - 1 );
_3b_nonnegative =      sign( sign(value) + 1 );
_3b_negative    =  1 - sign( sign(value) + 1 );
_3b_nonpositive =    - sign( sign(value) - 1 );
special_neg = ifn(missing(value),value,-value);
label
value = 'Given: x'
negation = 'Negation: - x'
abs = 'Absolute value: abs(x)'
miss2zero = 'Zero in place of missing: sum(x,0)'
sign = 'Remove magnitude: sign(x)'
missing = 'Missingness: missing(x)'
divisor = 'Divisor suitability: x NE 0'
not =    'False:     not x'
boolean = 'True: not not x'
positive =        'Positive: sign(x) EQ       1'
nonnegative = 'Non-negative: sign(x) IN (   0,1)'
negative =        'Negative: sign(x) EQ  -1'
nonpositive = 'Non-positive: sign(x) IN (-1,0)'
_3b_not =    'False (3-branch):  1 - abs( sign(x) )'
_3b_boolean = 'True (3-branch):      abs( sign(x) )'
_3b_positive =        'Positive (3-branch): 1 + sign( sign(x) - 1 )'
_3b_nonnegative = 'Non-negative (3-branch):     sign( sign(x) + 1 )'
_3b_negative =        'Negative (3-branch): 1 - sign( sign(x) + 1 )'
_3b_nonpositive = 'Non-positive (3-branch):   - sign( sign(x) - 1 )'
special_neg = 'Negation (special): ifn(missing(x),x,-x)'
;
run;

proc transpose data=value_x_formula out=formula_x_value;
id monotone;
idlabel _label_;
run;

data _null_;
set formula_x_value;
if _n_=1 then do;
array hh(7) _1-_7;
put @31 @;
do j = 1 to 7;
h = vlabel( hh(j) );
put h \$7.-R @;
end;
put / @31 7*'  -----' /;
end;
L1 = scan(_label_,1,':');
L2 = scan(_label_,2,':');
put L1 \$char51. / L2 \$char30. @31 (_1-_7)(best7.-R) /;
run;```