<?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: Read a truly numeric variable as numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354223#M82831</link>
    <description>&lt;P&gt;Without doing a data step/infile I'm not sure how you can control in informat, but doing a second data step after the import is how I've handled this in the past.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dig2;
  set dig;
  BMI2 = input(BMI,6.3);
run;

/* or, to reuse the variable name already established */

data dig2(drop=_BMI);
  set dig(rename=(BMI=_BMI));
  BMI = input(_BMI,6.3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2017 18:21:06 GMT</pubDate>
    <dc:creator>JoshB</dc:creator>
    <dc:date>2017-04-27T18:21:06Z</dc:date>
    <item>
      <title>Read a truly numeric variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354221#M82830</link>
      <description>&lt;P&gt;I am trying to do some analyses on a variable that SAS&amp;nbsp;read in as character when it is numeric. I read it the data in as a csv with proc import. There are 100 variables but here is a snippet:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; BMI&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 25.987&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 23.192&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 29.901&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 21.009&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my code to read it in is&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile='~/dig_sas.csv'&lt;BR /&gt;out=dig&lt;BR /&gt;DBMS=csv&lt;BR /&gt;replace;&lt;BR /&gt;guessingrows=MAX;&lt;BR /&gt;getnames=YES;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It reads in BMI as character. I couldn't get the correct informat/ format (should be 6.3) in further steps. I also tried doing an input statement but coudn't get it to work. I don't want to do a data step with an infile/input because there are so many variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 18:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354221#M82830</guid>
      <dc:creator>lnicholl9</dc:creator>
      <dc:date>2017-04-27T18:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Read a truly numeric variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354223#M82831</link>
      <description>&lt;P&gt;Without doing a data step/infile I'm not sure how you can control in informat, but doing a second data step after the import is how I've handled this in the past.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dig2;
  set dig;
  BMI2 = input(BMI,6.3);
run;

/* or, to reuse the variable name already established */

data dig2(drop=_BMI);
  set dig(rename=(BMI=_BMI));
  BMI = input(_BMI,6.3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2017 18:21:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354223#M82831</guid>
      <dc:creator>JoshB</dc:creator>
      <dc:date>2017-04-27T18:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Read a truly numeric variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354225#M82833</link>
      <description>&lt;P&gt;Since it read it as character, I would guess that one or more records have a value that isn't numeric. I'd simply fix the problem with a very short data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input bmi $;
  cards;
29.901
21.009
x
22.4
;

data want (drop=_:);
  set have (rename=(bmi=_bmi));
  bmi=input(_bmi,?? 8.);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.s. the ?? is to set the value to missing if it isn't numeric and not cause SAS to consider it an error&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 18:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354225#M82833</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-27T18:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Read a truly numeric variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354261#M82849</link>
      <description>&lt;P&gt;If you want control over the process, then don't use proc import. It's that simple.&lt;/P&gt;
&lt;P&gt;See Maxim 22.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 19:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354261#M82849</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-27T19:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read a truly numeric variable as numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354304#M82863</link>
      <description>&lt;P&gt;Show use some values that are character. I suspect that you have something such as NULL, NA, N/A or similar in the data somewhere and occuring often enough that the GUESSING elment of Proc import says it is character. If you know the first 5 rows are actually numeric in appearance them perhaps use Guessingrows=5 (or what ever number of rows at the top work) but his may cause issues with lengths of other character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or write a data step. The proc import code generated one and it should be in the log that you could copy, paste into the editor and modify the informat to be best6. or similar instead of the extemely likely $6. .&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 22:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-a-truly-numeric-variable-as-numeric/m-p/354304#M82863</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-27T22:40:54Z</dc:date>
    </item>
  </channel>
</rss>

