<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Input function against 0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61301#M13309</link>
    <description>Hi:&lt;BR /&gt;
  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:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data convert;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input string $;&lt;BR /&gt;
  newvar = input(string,best.);&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
0&lt;BR /&gt;
1&lt;BR /&gt;
33333&lt;BR /&gt;
fred&lt;BR /&gt;
.4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
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:&lt;BR /&gt;
1) get an ERROR=1 condition and a NOTE in the SAS log and&lt;BR /&gt;
2) get a missing value in the numeric variable, as shown below:&lt;BR /&gt;
[pre]&lt;BR /&gt;
NOTE: Invalid argument to function INPUT at line 129 column 12.&lt;BR /&gt;
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+&lt;BR /&gt;
135        fred&lt;BR /&gt;
string=fred newvar=. _ERROR_=1 _N_=4&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                           &lt;BR /&gt;
If you then run the PROC PRINTs (shown at the end), you will get the output as shown at the bottom of this post.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
        &lt;BR /&gt;
[pre]&lt;BR /&gt;
142  proc print data=convert;&lt;BR /&gt;
143    title 'Using the INPUT function';&lt;BR /&gt;
144  run;&lt;BR /&gt;
                              &lt;BR /&gt;
NOTE: There were 5 observations read from the data set WORK.CONVERT.&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
                     &lt;BR /&gt;
145&lt;BR /&gt;
146  proc print data=convert;&lt;BR /&gt;
147    title 'What values are 0';&lt;BR /&gt;
148    where newvar = 0;&lt;BR /&gt;
149  run;&lt;BR /&gt;
                   &lt;BR /&gt;
NOTE: There were 1 observations read from the data set WORK.CONVERT.&lt;BR /&gt;
      WHERE newvar=0;&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
                   &lt;BR /&gt;
150&lt;BR /&gt;
151  proc print data=convert;&lt;BR /&gt;
152    title 'What values are missing';&lt;BR /&gt;
153    where newvar = .;&lt;BR /&gt;
154  run;&lt;BR /&gt;
                    &lt;BR /&gt;
NOTE: There were 1 observations read from the data set WORK.CONVERT.&lt;BR /&gt;
      WHERE newvar=.;&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
              &lt;BR /&gt;
The Results from the LISTING window:&lt;BR /&gt;
[pre]&lt;BR /&gt;
***First PROC PRINT:&lt;BR /&gt;
                         &lt;BR /&gt;
Using the INPUT function&lt;BR /&gt;
                            &lt;BR /&gt;
Obs    string     newvar&lt;BR /&gt;
 1     0             0.0&lt;BR /&gt;
 2     1             1.0&lt;BR /&gt;
 3     33333     33333.0&lt;BR /&gt;
 4     fred           .&lt;BR /&gt;
 5     .4            0.4&lt;BR /&gt;
&lt;BR /&gt;
                 &lt;BR /&gt;
***Second PROC PRINT:&lt;BR /&gt;
    &lt;BR /&gt;
What values are 0&lt;BR /&gt;
                           &lt;BR /&gt;
Obs    string    newvar&lt;BR /&gt;
 1       0          0&lt;BR /&gt;
           &lt;BR /&gt;
***Third PROC PRINT:&lt;BR /&gt;
               &lt;BR /&gt;
What values are missing&lt;BR /&gt;
               &lt;BR /&gt;
Obs    string    newvar&lt;BR /&gt;
 4      fred        .&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
    <pubDate>Wed, 24 Feb 2010 01:10:20 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-02-24T01:10:20Z</dc:date>
    <item>
      <title>Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61297#M13305</link>
      <description>Hi,&lt;BR /&gt;
Is there a diffrence between using Input function and zero ?</description>
      <pubDate>Tue, 23 Feb 2010 09:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61297#M13305</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2010-02-23T09:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61298#M13306</link>
      <description>?????&lt;BR /&gt;
I'm now very curious if someone will understand your question.</description>
      <pubDate>Tue, 23 Feb 2010 11:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61298#M13306</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-02-23T11:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61299#M13307</link>
      <description>Yes, there is.</description>
      <pubDate>Tue, 23 Feb 2010 12:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61299#M13307</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-02-23T12:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61300#M13308</link>
      <description>input function is used to covert character values into numeric values. i just don't get why compare it to zero. they are totally different</description>
      <pubDate>Wed, 24 Feb 2010 00:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61300#M13308</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2010-02-24T00:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61301#M13309</link>
      <description>Hi:&lt;BR /&gt;
  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:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data convert;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input string $;&lt;BR /&gt;
  newvar = input(string,best.);&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
0&lt;BR /&gt;
1&lt;BR /&gt;
33333&lt;BR /&gt;
fred&lt;BR /&gt;
.4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
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:&lt;BR /&gt;
1) get an ERROR=1 condition and a NOTE in the SAS log and&lt;BR /&gt;
2) get a missing value in the numeric variable, as shown below:&lt;BR /&gt;
[pre]&lt;BR /&gt;
NOTE: Invalid argument to function INPUT at line 129 column 12.&lt;BR /&gt;
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+&lt;BR /&gt;
135        fred&lt;BR /&gt;
string=fred newvar=. _ERROR_=1 _N_=4&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                           &lt;BR /&gt;
If you then run the PROC PRINTs (shown at the end), you will get the output as shown at the bottom of this post.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
        &lt;BR /&gt;
[pre]&lt;BR /&gt;
142  proc print data=convert;&lt;BR /&gt;
143    title 'Using the INPUT function';&lt;BR /&gt;
144  run;&lt;BR /&gt;
                              &lt;BR /&gt;
NOTE: There were 5 observations read from the data set WORK.CONVERT.&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
                     &lt;BR /&gt;
145&lt;BR /&gt;
146  proc print data=convert;&lt;BR /&gt;
147    title 'What values are 0';&lt;BR /&gt;
148    where newvar = 0;&lt;BR /&gt;
149  run;&lt;BR /&gt;
                   &lt;BR /&gt;
NOTE: There were 1 observations read from the data set WORK.CONVERT.&lt;BR /&gt;
      WHERE newvar=0;&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
                   &lt;BR /&gt;
150&lt;BR /&gt;
151  proc print data=convert;&lt;BR /&gt;
152    title 'What values are missing';&lt;BR /&gt;
153    where newvar = .;&lt;BR /&gt;
154  run;&lt;BR /&gt;
                    &lt;BR /&gt;
NOTE: There were 1 observations read from the data set WORK.CONVERT.&lt;BR /&gt;
      WHERE newvar=.;&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
              &lt;BR /&gt;
The Results from the LISTING window:&lt;BR /&gt;
[pre]&lt;BR /&gt;
***First PROC PRINT:&lt;BR /&gt;
                         &lt;BR /&gt;
Using the INPUT function&lt;BR /&gt;
                            &lt;BR /&gt;
Obs    string     newvar&lt;BR /&gt;
 1     0             0.0&lt;BR /&gt;
 2     1             1.0&lt;BR /&gt;
 3     33333     33333.0&lt;BR /&gt;
 4     fred           .&lt;BR /&gt;
 5     .4            0.4&lt;BR /&gt;
&lt;BR /&gt;
                 &lt;BR /&gt;
***Second PROC PRINT:&lt;BR /&gt;
    &lt;BR /&gt;
What values are 0&lt;BR /&gt;
                           &lt;BR /&gt;
Obs    string    newvar&lt;BR /&gt;
 1       0          0&lt;BR /&gt;
           &lt;BR /&gt;
***Third PROC PRINT:&lt;BR /&gt;
               &lt;BR /&gt;
What values are missing&lt;BR /&gt;
               &lt;BR /&gt;
Obs    string    newvar&lt;BR /&gt;
 4      fred        .&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 24 Feb 2010 01:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61301#M13309</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-02-24T01:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61302#M13310</link>
      <description>Wow, Cynthia - you are a true information / knowledge champion in my opinion!&lt;BR /&gt;
&lt;BR /&gt;
Scott</description>
      <pubDate>Wed, 24 Feb 2010 03:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61302#M13310</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-02-24T03:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Input function against 0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61303#M13311</link>
      <description>Hi Cynthia,&lt;BR /&gt;
Thanks alot !!!!</description>
      <pubDate>Wed, 24 Feb 2010 11:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-function-against-0/m-p/61303#M13311</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2010-02-24T11:15:37Z</dc:date>
    </item>
  </channel>
</rss>

