A dot(.) in numeric variable in SAS means "missing value", e.g.
data test;
a = 17;
b = 42;
c = .;
run;
this will create a data set Test with 3 variables, a, b, and c, but c will have missing value.
In SAS, in comparison expressions a missing value is considered to be "less than any number", so in the IF expressions like:
if c<a then ...
if c<b then ..
both will be evaluated as true.
So if you have data like this:
data have;
input HospitalDay MethadoneStartDate;
cards;
20 50
50 20
20 .
;
run;
the last observation in the code like this:
data want;
set have;
if MethadoneStartDate < HospitalDay then Methadone = 1;
else Methadone = 0;
run;
will be evaluated to true and Methadone will be set to 1.
You need to add some additional test MethadoneStartDate to be not missing, e.g.;
data want;
set have;
if . < MethadoneStartDate < HospitalDay then Methadone = 1;
else Methadone = 0;
run;
In this case condition says: MethadoneStartDate must be greater than missing value (which means to be non missing) and smaller than HospitalDay.
Hope it helps.
Bart