BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mgarret
Obsidian | Level 7

Hi all--

I have a data set which looks like this:

KPIControlTest
Response Rate0.00370.0032
Conversion Rate0.34010.3406
Yield0.00120.0011
Online Response Rate0.00150.0012
Total Response Rate0.00510.0044
Total Yield0.00140.0012
CPR68.165.5
CPS251.69237.99

I have to have  the CPR and CPS values formatted dollar10.2  and the rest of the KPIs formatted Percent10.2. So, the data set should look like this:

KPIControlTest
Response Rate0.37%0.32%
Conversion Rate34.01%34.06%
Yield0.12%0.11%
Online Response Rate0.15%0.12%
Total Response Rate0.51%0.44%
Total Yield0.14%0.12%
CPR$68.10$65.50
CPS$251.69$237.99

Is there a way to apply two formats to one variable?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You can nest the formats, if you can assume the percentages will be between 0-1 and all others will be higher.

proc format;

    value mixed_fmt

     0 -1 = [percent10.2]

     1-high = [dollar10.2];

run;

data want;

set have;

format control test mixed_fmt.;

run;

View solution in original post

2 REPLIES 2
Reeza
Super User

You can nest the formats, if you can assume the percentages will be between 0-1 and all others will be higher.

proc format;

    value mixed_fmt

     0 -1 = [percent10.2]

     1-high = [dollar10.2];

run;

data want;

set have;

format control test mixed_fmt.;

run;

LinusH
Tourmaline | Level 20

This sounds like a reporting requirement, surely not a must for storage. If one is to store different kind of values in the same variable in permanent storage, I would have some helper variable specifying the nature of the measures.

Reezas suggestion will probably work for many situations, but results kind be weird if you have a $0 result, or want to introduce other kind of measures, like diff last month etc.

Perhaps you could accomplish this in the presentation layer instead?

Data never sleeps

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2815 views
  • 0 likes
  • 3 in conversation