From: Yaw on 16 Apr 2010 20:47 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
From: Reeza on 16 Apr 2010 21:01 On Apr 16, 5:47 pm, Yaw <link...(a)gmail.com> wrote: > 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 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.
From: Yaw on 16 Apr 2010 22:32 On Apr 16, 8:01 pm, Reeza <fkhurs...(a)hotmail.com> wrote: > On Apr 16, 5:47 pm, Yaw <link...(a)gmail.com> wrote: > > > > > 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 > > 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. I want to merge by age bins(range); which are already in 1.0 mo increments. Ages are labeled at their mid points.
From: Patrick on 18 Apr 2010 01:00 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;
|
Pages: 1 Prev: how to use macro variable for file name Next: sas questions |