@Bumble_15 wrote:
Hello,
I have a dataset with a variable "age" that is continuous, but contains "<1". I am looking to replace the "<1" with a range of numeric values (0.3-0.7). The data I have is for individuals and looks like:
data have;
input individual age visit;
datalines;
1 <1 1
1 12 2
1 13 3
2 <1 1
2 4 2
2 5 3
3 <1 1
4 <1 1
5 <1 1
6 3 1
7 9 1
8 <1 1
;
run;
I can't seem to figure out what code may work. I initially though proc MI but that may be overcomplicating the situation?
Thank you!
That description is not very clear. Do you want to replace some of the <1 with a single value of 0.3, and others with a single value of 0.4, 0.5 (or other single numeric values) or do want the <1 to display in printed output as (0.3-0.7)?
The latter display option would be to use a custom format.
If you want to randomly assign a numeric value in the range of 0.3 to 0.7 then questions come up about how many decimals do you want to allow in that range. The RAND function with the UNIFORM option will create numeric values in an interval.
data junk;
do i=1 to 25;
x=rand('uniform',.03,.07) ;
output;
end;
run;
Round the values if you don't want lots of decimals.
To convert your existing data: (You would have to read age a character to get a value like "<1")
data have;
input individual age $ visit;
datalines;
1 <1 1
1 12 2
1 13 3
2 <1 1
2 4 2
2 5 3
3 <1 1
4 <1 1
5 <1 1
6 3 1
7 9 1
8 <1 1
;
data want;
set have;
if age='<1' then agenum= rand('UNIFORM',0.3,0.7);
else agenum = input(age,2.);
run;
... View more