Hello Experts,
I would like to taste if my rate (Taux) is equal +/- 5%. My code is :
proc means data=RP_EA7 noprint;
class cle;
var Taux;
output out=RP_EA7_STAT stddev=stddev;
run;
data RP_EA8_STAT;
length Commentaire $50;
set RP_EA7_STAT;
if _type_=0 then
delete;
if stddev<0.05 then
Commentaire='Taux égaux';
else if stddev=. then
Commentaire='Une seule valeur';
else Commentaire='Valeurs ne sont pas égaux’;
run;
But I think that STDDEV is not a good indicator (I would like to have a value +- 5%). Do you know, please, another way to do this selection?
Thank you!
Is this what you want?
proc means data=sashelp.cars nway noprint;
class Make;
var Invoice;
output out=RP_EA7_STAT min= median= max= / autoname;
run;
data RP_EA8_STAT;
length Commentaire $50;
set RP_EA7_STAT;
*if _type_=0 then delete;
if _FREQ_=1 then Commentaire='Une seule valeur';
else if Invoice_Min > (0.95*Invoice_Median) and Invoice_Max < (1.05*Invoice_Median)
then Commentaire='Taux égaux';
else Commentaire='Valeurs ne sont pas égaux';
run;
/* end of program */
BR,
Koen
Is this what you want?
proc means data=sashelp.cars nway noprint;
class Make;
var Invoice;
output out=RP_EA7_STAT min= median= max= / autoname;
run;
data RP_EA8_STAT;
length Commentaire $50;
set RP_EA7_STAT;
*if _type_=0 then delete;
if _FREQ_=1 then Commentaire='Une seule valeur';
else if Invoice_Min > (0.95*Invoice_Median) and Invoice_Max < (1.05*Invoice_Median)
then Commentaire='Taux égaux';
else Commentaire='Valeurs ne sont pas égaux';
run;
/* end of program */
BR,
Koen
Thank you!That works !Could you explain please why ypu take the Median and not Mean ?
@SASdevAnneMarie wrote:
Thank you!That works !Could you explain please why you take the Median and not Mean ?
In case of a heavily skewed distribution, the median (to me) is a better central tendency measure than the mean.
You could also check whether Max < (1.10*Min).
This means you take the midpoint (halfway point between min and max) instead of median.
I believe both midpoint and median are a better choice than mean for what you want to achieve.
else if Invoice_Max < (1.10*Invoice_Min) then Commentaire='Taux égaux';
BR,
Koen
I have another question, Koen. Why you wrote : Max < (1.10*Min). Why do you use 1.10 ?
@SASdevAnneMarie wrote:
I have another question, Koen. Why you wrote : Max < (1.10*Min). Why do you use 1.10 ?
Because +/- 5% around the midpoint (halfway point) is a range of 10%.
Koen
Thank you ! Min=Midpoint in this case ?
@SASdevAnneMarie wrote:
Thank you ! Min=Midpoint in this case ?
No.
But midpoint minus 5% should contain MIN.
And midpoint plus 5% should contain MAX.
That's (almost!) the same as saying that MAX should be within 1.10 times MIN.
That's (almost!) the same as saying that MIN should be within 0.90 times MAX.
If you want it exact, you need to calculate the exact midpoint between MIN and MAX and subsequently check whether MIN and MAX are
within the interval [0.95 * midpoint ; 1.05 * midpoint].
BR, Koen
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: