|
|
Rounding/Merging
Dear All:
I have age variable in my data set I want to round to .5 (up or
down).
Example
Data have;
Agemos
24.9
25.2
26.1
27.5
28.1
29.7
The data set I want to merge with are all 1month increment from 0.5.
Agecat
24.5
25.5
26.5
27.5
28.5
29.5
30.5
So my task is trying to, by some way round up or down all my ages to
enable them to be compatible with the form of the I want to merge
with.
Rounding 28.1 up to 28.5 or 29.7 to 29.5 is okay for example. In fact
that what I want to do.
Any ideas?
Thanks in advance
|
|
0
|
|
|
|
Reply
|
Yaw
|
4/17/2010 12:47:49 AM |
|
On Apr 16, 5:47=A0pm, Yaw <link...@gmail.com> wrote:
> Dear All:
>
> I have age variable in my data set I want to round to .5 (up or
> down).
>
> Example
>
> Data =A0have;
> Agemos
> =A0 24.9
> =A0 25.2
> =A0 26.1
> =A0 27.5
> =A0 28.1
> =A029.7
>
> The data set I want to merge with are all 1month increment from 0.5.
>
> Agecat
> 24.5
> 25.5
> 26.5
> 27.5
> 28.5
> 29.5
> 30.5
>
> So my task is trying to, by some way round up or down all my ages to
> enable them to be compatible with the form of the I want to merge
> with.
>
> Rounding 28.1 up to 28.5 or 29.7 to 29.5 is okay for example. In fact
> that what I want to do.
>
> Any ideas?
>
> Thanks in advance
Apply round/floor or ceiling to the number then subtract 0.5? or add
0.5? ...not sure what the rules are.
In both cases you presented, floor(argument) +0.5 would work.
Why should 28.1 go to 28.5 and 29.7 to 29.5.
|
|
0
|
|
|
|
Reply
|
Reeza
|
4/17/2010 1:01:06 AM
|
|
On Apr 16, 8:01=A0pm, Reeza <fkhurs...@hotmail.com> wrote:
> On Apr 16, 5:47=A0pm, Yaw <link...@gmail.com> wrote:
>
>
>
> > Dear All:
>
> > I have age variable in my data set I want to round to .5 (up or
> > down).
>
> > Example
>
> > Data =A0have;
> > Agemos
> > =A0 24.9
> > =A0 25.2
> > =A0 26.1
> > =A0 27.5
> > =A0 28.1
> > =A029.7
>
> > The data set I want to merge with are all 1month increment from 0.5.
>
> > Agecat
> > 24.5
> > 25.5
> > 26.5
> > 27.5
> > 28.5
> > 29.5
> > 30.5
>
> > So my task is trying to, by some way round up or down all my ages to
> > enable them to be compatible with the form of the I want to merge
> > with.
>
> > Rounding 28.1 up to 28.5 or 29.7 to 29.5 is okay for example. In fact
> > that what I want to do.
>
> > Any ideas?
>
> > Thanks in advance
>
> Apply round/floor or ceiling to the number then subtract 0.5? =A0or add
> 0.5? ...not sure what the rules are.
> In both cases you presented, floor(argument) +0.5 would work.
>
> Why should 28.1 go to 28.5 and 29.7 to 29.5.
I want to merge by age bins(range); which are already in 1.0 mo
increments. Ages are labeled at their mid points.
|
|
0
|
|
|
|
Reply
|
Yaw
|
4/17/2010 2:32:42 AM
|
|
As Reeza suggested:
Data have;
input AgeMos;
datalines;
24.9
25.2
26.1
27.5
28.1
29.7
;
run;
data AgeCats;
input AgeCat;
datalines;
24.5
25.5
26.5
27.5
28.5
29.5
30.5
;
run;
proc sql;
select l.AgeMos, r.AgeCat
from have as l left join AgeCats as r
on r.AgeCat= (floor(l.AgeMos)+0.5)
;
quit;
|
|
0
|
|
|
|
Reply
|
Patrick
|
4/18/2010 5:00:08 AM
|
|
|
3 Replies
344 Views
(page loaded in 0.98 seconds)
|
|
|
|
|
|
|
|
|