BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11

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!

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

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

View solution in original post

9 REPLIES 9
sbxkoenk
SAS Super FREQ

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

SASdevAnneMarie
Barite | Level 11

Thank you!That works !Could you explain please why ypu take the Median and not Mean ?

sbxkoenk
SAS Super FREQ

@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

SASdevAnneMarie
Barite | Level 11
Thank you!
SASdevAnneMarie
Barite | Level 11

I have another question, Koen. Why you wrote : Max < (1.10*Min). Why do you use 1.10 ?

sbxkoenk
SAS Super FREQ

@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

SASdevAnneMarie
Barite | Level 11

Thank you ! Min=Midpoint in this case ?

sbxkoenk
SAS Super FREQ

@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

SASdevAnneMarie
Barite | Level 11
Thank you Koen!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

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