| Date: | Tue, 10 Jun 2003 09:03:18 -0400 |
| Reply-To: | John Kirkpatrick <johnk_uk@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | John Kirkpatrick <johnk_uk@HOTMAIL.COM> |
| Subject: | Re: Problem with generating quartiles (rounding errors??) |
|---|
It's also possible for the code to be working correctly and simply
reporting a feature of the data. Consider the data set {1, 2, 4, 4}. The
upper quartile and maximum are both 4, so I think this would exhibit the
same behaviour as Mark's dataset.
Perhaps that's the reason.
HTH,
John
On Tue, 10 Jun 2003 08:37:45 -0400, Howard Schreier
<Howard_Schreier@ITA.DOC.GOV> wrote:
>It's not macro arithmetic, because there is no macro arithmetic taking
>place.
>
>I cannot replicate the problem. The implicit numeric to character
>conversions within the SYMPUT calls should use the BEST format and avoid
>all but the slightest rounding.
>
>I do notice that that a SELECT statement is missing in the final DATA step.
>I would try it again after making that correction.
>
>Another strategy would be to abandon this code and use PROC RANK to do the
>quartiles directly.
>
>On Mon, 9 Jun 2003 20:19:31 GMT, Mark AC Emmett <markacemmett@AOL.COM>
>wrote:
>
>>Hello all,
>>
>>I seem to be producing something which is not possible - the only
>explanation I
>>can think of is rounding errors - can anyone help:
>>
>>I use proc means to generate the quartiles for my dataset
>>
>>proc means data = temp1 noprint;
>>var Variable;
>>output out=temp2 min=min q1=q1 median=median q3=q3 max=max;
>>run;
>>
>>data quartiles;
>>set temp2;
>>call symput('Min',min);
>>call symput('Max',max);
>>call symput('Median',median);
>>call symput('Q1',q1);
>>call symput('Q3',q3);
>>run;
>>
>>I then code up my other dataset with the quartiles:
>>
>>
>>data maindata;
>>set temp1;
>>when (Variable ge &Min and Variable le &Q1) ExportCat='A';
>>when (Variable gt &Q1 and Variable le &Median) ExportCat='B';
>>when (Variable gt &Median and Variable le &Q3) ExportCat='C';
>>when (Variable gt &Q3 and Variable le &Max) ExportCat='D';
>>otherwise ExportCat='QQ';
>>end;
>>
>>Now when I look at my Variable ExportCat I find that there are instances
>of QQ
>>in there and no D.
>>
>>When I use a %put to show my quartiles I find the following:
>>
>>ExpMin = 2
>>ExpQ1=29
>>ExpMedian=75
>>ExpQ3=100
>>ExpMax=100
>>
>>How can the 3rd quartile be the same as the maximum value when I tell proc
>>means to produce the quartiles? Surely the ExpQ3 value is something like
>99.7?
>> But if so, why do no instances of ExportCat=D occur and QQ does??
>>
>>Any help would be very appreciated
>>Thank you
>>Mark
|