| Date: | Tue, 23 Feb 2010 11:18:30 -0500 |
| Reply-To: | My Name <lewjord@UGA.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | My Name <lewjord@UGA.EDU> |
| Subject: | Re: How to Find the nearest multiple of 10 |
|
| In-Reply-To: | <191171.79697.qm@web32403.mail.mud.yahoo.com> |
| Content-Type: | text/plain; charset=us-ascii |
Wouldn't something like this work, but of course implemented in PROC SQL?
data one;
x1=62.87;
x2=10+x1-mod(x1,10);
proc print;
run;
---- Original message ----
>Date: Mon, 22 Feb 2010 13:54:55 -0800
>From: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> (on behalf of Dale McLerran <stringplayer_2@YAHOO.COM>)
>Subject: Re: How to Find the nearest multiple of 10
>To: SAS-L@LISTSERV.UGA.EDU
>
>Mike's solution assumes that the observed values are all integers.
>I would suggest a different implementation using floor and ceil
>functions as follows:
>
>proc sql noprint;
> select min(10*floor(x/10)), max(10*ceil(x/10)) into :min, :max
> from x;
>quit;
>
>
>I do agree with xlr82sas that a general solution for determining
>appropriate axis values is not a trivial problem. If the range
>of the data is from 40 to 60, then should we increment by 5
>instead of 10? If the range is from 0 to 100, should we
>increment by 10? By 20? By 25?
>
>How about if the range is from 10 to 100? Should we start with
>a minimum axis value of 0 rather than 10? If so, then we have
>exactly the same question about what value to increment by. Or,
>should we start at 0 and have our range extend up to 120 or 125?
>With a range from 0 to 120, we would probably increment by 20
>or 30. With a range from 0 to 125, we would likely increment
>by 25.
>
>This is only a small list of issues that need to be dealt with
>which arise when the range is known a priori to have a range
>which can utilize an interval of around 10 for axis construction.
>If such knowledge is not known a priori, then there are many
>more issues which need to be assessed and dealt with.
>
>Dale
>
>---------------------------------------
>Dale McLerran
>Fred Hutchinson Cancer Research Center
>mailto: dmclerra@NO_SPAMfhcrc.org
>Ph: (206) 667-2926
>Fax: (206) 667-5977
>---------------------------------------
>
>
>--- On Mon, 2/22/10, Mike Zdeb <msz03@ALBANY.EDU> wrote:
>
>> From: Mike Zdeb <msz03@ALBANY.EDU>
>> Subject: Re: How to Find the nearest multiple of 10
>> To: SAS-L@LISTSERV.UGA.EDU
>> Date: Monday, February 22, 2010, 10:32 AM
>> hi ... you can try the round function
>> ...
>>
>>
>>
>> data _null_;
>> file print;
>> do x1=40 to 60;
>> x2= round(x,10);
>> x3= round(x-4,10);
>> x4= round(x+4,10);
>> put (x1-x4) (5.);
>> end;
>> run;
>>
>> 40 40 40 40
>> 41 40 40 50
>> 42 40 40 50
>> 43 40 40 50
>> 44 40 40 50
>> 45 50 40 50
>> 46 50 40 50
>> 47 50 40 50
>> 48 50 40 50
>> 49 50 50 50
>> 50 50 50 50
>> 51 50 50 60
>> 52 50 50 60
>> 53 50 50 60
>> 54 50 50 60
>> 55 60 50 60
>> 56 60 50 60
>> 57 60 50 60
>> 58 60 50 60
>> 59 60 60 60
>> 60 60 60 60
>>
>>
>> so ... here's an example, x varies from a low of 42 to a max of 52
>> I think you would want your axis to go from 40 to 60 ... yes/no?
>> if I'm wrong, I think that youc can figure out how to modify the
>> following ...
>>
>> data x;
>> do x=42 to 52;
>> output;
>> end;
>> run;
>>
>> proc sql noprint;
>> select min(round(x-4,10)), max(round(x+4,10)) into :min, :max
>> from x;
>> quit;
>>
>> %put MIN:&min MAX:&max;
>> MIN: 40 MAX:
>> 60
>>
>>
>>
>>
>>
>> --
>> Mike Zdeb
>> U@Albany School of Public Health
>> One University Place
>> Rensselaer, New York 12144-3456
>> P/518-402-6479 F/630-604-1475
>>
>> > Hello all,
>> >
>> > In the Process of making the graph coordinates I am calculating the
>> > Min and Max in the Axis one I am doing something like this. Is
>> > there way (General rule) to find out the nearest multiple of 10 , I
>> > mean if the Min is 42 then I want value 50 , if it is 52 then I want
>> > value to 60. so that when I divide with 10 I get reminder as 0 . I
>> > hope I am clear what I am asking
>> >
>> >
>> _________________________________________________________
>> >
>> > 16 Proc Sql Noprint ;
>> > 17 Select FUZZ(Ceil(Min(max))), FUZZ(Ceil(Max(max)))
>> > 19 into : Min_y, : Max_Y
>> > 21 From Best;
>> > 22 %put &min_y &max_y ;
>> > -70 142
>> > 23 Quit;
>> >
>> > axis1 label=(a=90 H=3 "Percent Change")
>> > VALUE=(H=2)
>> > ORDER=(&min_y. TO &max_y. BY 10)
>> > WIDTH=1
>> > MINOR=NONE
>> > ;
>> >
>>
|