<?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: problem in read numeric value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500325#M133223</link>
    <description>&lt;P&gt;When using an informat, it is usually not necessary (and in fact causes problems) to specify the fractional part.&lt;/P&gt;
&lt;P&gt;See the documentation: &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n14sqpf1cubqknn1vmkzkp1oph87.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n14sqpf1cubqknn1vmkzkp1oph87.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;By using 32.16, you forced SAS to divide all values by 10**16 (unless a decimal point is present in the input data, as that overrides the d in the w.d informat).&lt;/P&gt;
&lt;P&gt;Do this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue twodot
'..' = .
other = [32.]
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and use the colon modifier when reading, or you'll override the delimiters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data GDP;
infile datalines DLM=',' DSD truncover ;
input 
  val1 :twodot.
  val2 :twodot.
;
datalines;
..,8013233121.55065
185470260100,..
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 01 Oct 2018 12:32:09 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-10-01T12:32:09Z</dc:date>
    <item>
      <title>problem in read numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500316#M133220</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read the data by using following codes,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue twodot
'..' = .
other = [32.16]
;
run;

data sa_step1.GDP;
infile 'F:\Dataset\Control variables\Source\1.GDP World Development Indicators\eca1f3cd-082d-4f10-a504-2319bf5dbe50_Data.csv' DLM=',' DSD missover lrecl = 32767 firstobs =2 ;
  input 
        Country_Name :$50. 
        Country_Code :$29. 
        Series_Name :$250. 
        Series_Code :$250.  
        YR1980 :twodot. 
        YR1981 :twodot.
        YR1982 :twodot. 
        YR1983 :twodot.
        YR1984 :twodot.
        YR1985 :twodot. 
        YR1986 :twodot. 
        YR1987 :twodot. 
        YR1991 :twodot.  
        YR1992 :twodot.  
        YR1993 :twodot. 
        YR1994 :twodot.  
        YR1995 :twodot.  
        YR1996 :twodot.  
        YR1997 :twodot.  
        YR1998 :twodot.  
        YR1999 :twodot.  
        YR2000 :twodot.  
        YR2001 :twodot.  
        YR2002 :twodot.  
        YR2006 :twodot.  
        YR2007 :twodot.  
        YR2008 :twodot.   
        YR2009 :twodot.  
        YR2010 :twodot.  
        YR2011 :twodot.   
        YR2012 :twodot.  
        YR2013 :twodot.   
        YR2014 :twodot.  
        YR2015 :twodot.  
        YR2016 :twodot.   
        YR2017 :twodot.   
;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;however, the value in original data as&amp;nbsp;160599998500 shows in the new table as&amp;nbsp;0.00001606.&lt;/P&gt;&lt;P&gt;the value in original data as&amp;nbsp;15537999900 shows in the new table as&amp;nbsp;1.5538E-6.&lt;/P&gt;&lt;P&gt;Could you please give me some suggestions?&amp;nbsp;&lt;/P&gt;&lt;P&gt;the attachment is the original&amp;nbsp;data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 12:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500316#M133220</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-10-01T12:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: problem in read numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500325#M133223</link>
      <description>&lt;P&gt;When using an informat, it is usually not necessary (and in fact causes problems) to specify the fractional part.&lt;/P&gt;
&lt;P&gt;See the documentation: &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n14sqpf1cubqknn1vmkzkp1oph87.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=n14sqpf1cubqknn1vmkzkp1oph87.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;By using 32.16, you forced SAS to divide all values by 10**16 (unless a decimal point is present in the input data, as that overrides the d in the w.d informat).&lt;/P&gt;
&lt;P&gt;Do this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue twodot
'..' = .
other = [32.]
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and use the colon modifier when reading, or you'll override the delimiters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data GDP;
infile datalines DLM=',' DSD truncover ;
input 
  val1 :twodot.
  val2 :twodot.
;
datalines;
..,8013233121.55065
185470260100,..
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Oct 2018 12:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500325#M133223</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-01T12:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: problem in read numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500346#M133234</link>
      <description>&lt;P&gt;Dear Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your suggestions, and apologies for missing information。There is&amp;nbsp;&lt;SPAN&gt;a decimal point is present in the input data. B&lt;/SPAN&gt;y using the following codes&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
invalue twodot
'..' = .
other = [32.]
;
run;

data sa_step1.GDP;
infile 'F:\Dataset\Control variables\Source\1.GDP World Development Indicators\eca1f3cd-082d-4f10-a504-2319bf5dbe50_Data.csv' DLM=',' DSD missover lrecl = 32767 firstobs =2 ;
  input 
        Country_Name :$50. 
        Country_Code :$29. 
        Series_Name :$250. 
        Series_Code :$250.  
        YR1980 :twodot. 
        YR1981 :twodot.
        YR1982 :twodot. 
        YR1983 :twodot.
        YR1984 :twodot.
        YR1985 :twodot. 
        YR1986 :twodot. 
        YR1987 :twodot. 
        YR1991 :twodot.  
        YR1992 :twodot.  
        YR1993 :twodot. 
        YR1994 :twodot.  
        YR1995 :twodot.  
        YR1996 :twodot.  
        YR1997 :twodot.  
        YR1998 :twodot.  
        YR1999 :twodot.  
        YR2000 :twodot.  
        YR2001 :twodot.  
        YR2002 :twodot.  
        YR2006 :twodot.  
        YR2007 :twodot.  
        YR2008 :twodot.   
        YR2009 :twodot.  
        YR2010 :twodot.  
        YR2011 :twodot.   
        YR2012 :twodot.  
        YR2013 :twodot.   
        YR2014 :twodot.  
        YR2015 :twodot.  
        YR2016 :twodot.   
        YR2017 :twodot.   
;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;however, the value '5.74563529200682,2.94859680156875,1.10493826182693,-1.2515966446984' original data shows in the&amp;nbsp;viewtable&amp;nbsp;is '5.745635292, 2.9485968016,&amp;nbsp;1.1049382618,&amp;nbsp;-1.251596645'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;could you please give me more suggestions about it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;besides, I use missover&amp;nbsp;rather than turnover, because the length of each line is different. is it ok?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500346#M133234</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-10-01T13:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: problem in read numeric value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500367#M133249</link>
      <description>&lt;P&gt;You should always use truncover instead of missover.&lt;/P&gt;
&lt;P&gt;If you try to read 5 bytes but only have three characters in the last variable, missover will discard everything, while truncover gets you the three characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With sufficiently long numbers, use a proper display format; if you have lots of similar variables, SAS can help you with variable lists:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sa_step1.GDP;
infile 'F:\Dataset\Control variables\Source\1.GDP World Development Indicators\eca1f3cd-082d-4f10-a504-2319bf5dbe50_Data.csv' DLM=',' DSD missover lrecl = 32767 firstobs =2 ;
input 
  Country_Name :$50. 
  Country_Code :$29. 
  Series_Name :$250. 
  Series_Code :$250.  
  (YR1980-YR2017) (:twodot.) 
;
format YR1980-YR2017 32.16;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that my next step would be to normalize the data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
  data=sa_step1.gdp
  out=sa_step1.gdp_trans (
    compress=yes
    rename=(col1=gdp)
  )
;
by
  Country_Name notsorted
  Country_Code notsorted
  Series_Name notsorted
  Series_Code notsorted
;
var YR:;
run;

data sa_step1.gdp_final (compress=yes);
set sa_step1.gdp_trans;
year = input(substr(_name_,3),4.);
drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I use the compress option because of the long strings contained.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 13:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-in-read-numeric-value/m-p/500367#M133249</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-01T13:48:46Z</dc:date>
    </item>
  </channel>
</rss>

