Hi:
It seems to me that the original question must be part of a bigger question or issue. Since the INPUT function is used (as already explained) to convert a character variable value to a numeric variable value, the result of the INPUT function may not be as you expect. Consider the following program:
[pre]
data convert;
infile datalines;
input string $;
newvar = input(string,best.);
return;
datalines;
0
1
33333
fred
.4
;
run;
[/pre]
The INPUT function will be able to convert all the character strings to numbers except on observation 4. The string 'fred' is not a number. When the INPUT function is used on this value, you will:
1) get an ERROR=1 condition and a NOTE in the SAS log and
2) get a missing value in the numeric variable, as shown below:
[pre]
NOTE: Invalid argument to function INPUT at line 129 column 12.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+
135 fred
string=fred newvar=. _ERROR_=1 _N_=4
[/pre]
If you then run the PROC PRINTs (shown at the end), you will get the output as shown at the bottom of this post.
It might be possible, if you wanted to use 0 or 1 in Boolean expressions, that you might use the INPUT function to convert character zeroes or ones into a number so the Boolean expression would work without a warning about automatic conversion from character to numeric, but still, if you're not very sure about your data, the INPUT function could return something other than 0 or 1.
cynthia
[pre]
142 proc print data=convert;
143 title 'Using the INPUT function';
144 run;
NOTE: There were 5 observations read from the data set WORK.CONVERT.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
145
146 proc print data=convert;
147 title 'What values are 0';
148 where newvar = 0;
149 run;
NOTE: There were 1 observations read from the data set WORK.CONVERT.
WHERE newvar=0;
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
150
151 proc print data=convert;
152 title 'What values are missing';
153 where newvar = .;
154 run;
NOTE: There were 1 observations read from the data set WORK.CONVERT.
WHERE newvar=.;
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
[/pre]
The Results from the LISTING window:
[pre]
***First PROC PRINT:
Using the INPUT function
Obs string newvar
1 0 0.0
2 1 1.0
3 33333 33333.0
4 fred .
5 .4 0.4
***Second PROC PRINT:
What values are 0
Obs string newvar
1 0 0
***Third PROC PRINT:
What values are missing
Obs string newvar
4 fred .
[/pre]