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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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