I have inherited some code that creates a user-defined function and format (later used in proc tabulate statement) that is not working.
Can anyone help?
Code below:-
* Create a function that rounds small & missing numbers to zero (amended fromn standard supprnd function code as in this instance we need to create a numeric variable for later calculations); proc fcmp outlib=work.functions.misc; function suppf(x); length y 16; if ( missing(x) OR x in (1, 2) ) then y = 0; /* suppress disclosive values */ else do; x2 = round(x, 5); /* round to nearest 5 */ y = put(x2, 32.); end; return(compress(y)); endsub; /*Add function to round to nearest 10 for current cycle reporting*/ function suppt(x); length y 16; if ( missing(x) OR x in (1, 2) ) then y = 0; /* suppress disclosive values */ else do; x2 = round(x, 10); /* round to nearest 5 */ y = put(x2, 32.); end; return(compress(y)); endsub;
/* suppress disclosive values, but do not round other values */ function suppr_s(x) $; length y $30; if ( missing(x) OR x in (1, 2) ) then y = '--'; /* suppress disclosive values */ else do; y = put(x, 32.); end; return(compress(y)); endsub; run;
proc format; /* Format for rounding */ value supp_t other = [suppt()]; /* suppress disclosive values & round to nearest 10 */ value supp_f other = [suppf()]; /* suppress disclosive values & round to nearest 5 */ value suppress other = [suppr_s()]; /* suppress disclosive values only */ quit;
... View more