When using the SCORE statement in PROC LOGISTIC to score a new data set, if you also use a FORMAT statement in the LOGISTIC step to associate a format with a predictor in the model, then a message may be issued that the variable was not found in the data set.
For example, these statements generate some random data to serve as training (TRAIN) and validation (VALIDATE) data sets. A format, FNUM, is defined for use with variable X. The first PROC LOGISTIC step fits the model to the training data set and saves the model information in the data set OM. The second PROC LOGISTIC step uses the saved model to score the validation data set. A FORMAT statement is used in each PROC LOGISTIC step to associate the format FNUM with predictor X.
data train;
do i=1 to 30;
y=rantbl(234234,.5,.5);
x=rantbl(234234,.5,.5);
output;
end;
run;
proc format;
value fnum 1='a'
2='b';
run;
proc logistic data=train outmodel=om;
format x fnum.;
class x;
model y=x;
run;
data validate;
do i=1 to 30;
y=rantbl(5739,.5,.5);
x=rantbl(5739,.5,.5);
output;
end;
run;
proc logistic inmodel=om;
score data=validate out=valout;
format x fnum.;
run;
The second PROC LOGISTIC step produces the following message:
WARNING: Variable X not found in data set WORK.OM.
To avoid the problem, associate the format with the variable in the DATA step. These statements successfully score the validation data set.
data train;
do i=1 to 30;
y=rantbl(234234,.5,.5);
x=rantbl(234234,.5,.5);
output;
end;
format x fnum.;
run;
proc format;
value fnum 1='a'
2='b';
run;
proc logistic data=train outmodel=om;
class x;
model y=x;
run;
data validate;
do i=1 to 30;
y=rantbl(5739,.5,.5);
x=rantbl(5739,.5,.5);
output;
end;
format x fnum.;
run;
proc logistic inmodel=om;
score data=validate out=valout;
run;