Hi there!
I'm new to SAS programming, and trying to write the statement "In X patients of study, y% are not having data" in my ods statement, but the values are not getting calculated as expected.
Requirement:
I've two macro variables and I'd like to write a string to ods, in that string add a percentage calculated from the two macro variables.
%let x = 20;
%total = 150;
ods rtf text = "~S={outputwidth=100% just=c font=('Times New Roman',12pt)} { *In &x patients of study. (round(&x./&total. * 100,.02)%) are not having data}";
Question:
Seems like round function only works in data step, but here it's not working.
How can I calculate the percentage on the fly and include in the ods text.
Thanks a lot in advance!
It seems it's now time to learn how to use the %sysfunc function.
It seems it's now time to learn how to use the %sysfunc function.
To use a data step function like that, you need to wrap it in %sysfunc, and for calculations, you need either %eval (integer) or %sysevalf (floating point).
Since that would blow up the code and make it less readable, I prefer a data _null_ step:
data _null_;
call symputx('rate',put(&x./&total.,percent7.2));
run;
ods rtf text = "~S={outputwidth=100% just=c font=('Times New Roman',12pt)} { *In &total. patients of study, &rate. are not having data}"
Thank you so much @Kurt_Bremser , that worked!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.