Hi all--
I have a data set which looks like this:
KPI | Control | Test |
Response Rate | 0.0037 | 0.0032 |
Conversion Rate | 0.3401 | 0.3406 |
Yield | 0.0012 | 0.0011 |
Online Response Rate | 0.0015 | 0.0012 |
Total Response Rate | 0.0051 | 0.0044 |
Total Yield | 0.0014 | 0.0012 |
CPR | 68.1 | 65.5 |
CPS | 251.69 | 237.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:
KPI | Control | Test |
Response Rate | 0.37% | 0.32% |
Conversion Rate | 34.01% | 34.06% |
Yield | 0.12% | 0.11% |
Online Response Rate | 0.15% | 0.12% |
Total Response Rate | 0.51% | 0.44% |
Total Yield | 0.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!
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;
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;
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?
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.