I am trying to build a function in SAS that will concatenate and number and a percent value and return a character string result like X (Y%). Here is my code:
proc fcmp outlib = func.funcs.mwfunc;
/* Create function to return a string in the style X (Y%) */
function npct(n, pct) $ 25;
length concatp $25 n pct 8;
n_f = n;
pct_f = pct;
concatp = cat(n_f, " (", round(pct_f*100,0.01),"%",")");
/* Test function */
x = npct(5,0.10);
When I test this function, it produces the following result:
Instead of 5 (10%).
How do I correct this? Is there some kind of masking function I need?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.