BookmarkSubscribeRSS Feed
HS2
Fluorite | Level 6 HS2
Fluorite | Level 6

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.

3 REPLIES 3
Kurt_Bremser
Super User

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.

HS2
Fluorite | Level 6 HS2
Fluorite | Level 6
OK, so there is options for such raw presentation of the data.

Thank you!
FreelanceReinh
Jade | Level 19

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2148 views
  • 0 likes
  • 3 in conversation