Hello,
I am working on a variable that needs to be presented in fraction format, not decimal.
I know there is an existing format=FRACT. However it presents the reduced fraction which I don’t want to.
I want the derived data (Z) to be as follow :
X 2 5
Y 4 25
Z 2/4 5/25 and NOT 1/2 1/5
Can you please advise on this, knowing that I need the fraction for numerical calculation, so I cannot consider the CATX function.
I am using SAS 9.4 - ANALYTIC PRO WX6.
The value created by the calculation 5/25 is 0.2, and that's all that SAS can see when the format is applied. It could be 1/5, 5/25, 20/100, or any combination from an infinite list, and there's no way to guess which one you want at the moment. SAS just defaults to the most simple one.
Hello @HS2 and welcome to the SAS Support Communities!
I think the idea of using a format starts getting difficult when different pairs (X, Y) demand different labels (=formatted values) for the same numeric value of Z, e.g. (2, 4) and (3, 6).
My recommendation: Create a character variable, say ZC, in addition to the existing numeric variable Z and store the fractions (created from numerator and denominator using CATX as you've suggested) in ZC. Then you can perform calculations with Z and use ZC in your reports. Of course, it's your responsibility to make sure that the values of Z and ZC are consistent.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.