<?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: character to numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/718979#M27647</link>
    <description>&lt;P&gt;Do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   c = "20130101";
   d = input(c, yymmdd8.);
   format d yymmddn8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Feb 2021 19:10:32 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-02-12T19:10:32Z</dc:date>
    <item>
      <title>character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/718973#M27645</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a number "20130101" which is character&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want this to change to numeric. same format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 18:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/718973#M27645</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2021-02-12T18:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/718979#M27647</link>
      <description>&lt;P&gt;Do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   c = "20130101";
   d = input(c, yymmdd8.);
   format d yymmddn8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Feb 2021 19:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/718979#M27647</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-02-12T19:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/719039#M27651</link>
      <description>&lt;P&gt;The word FORMAT in SAS has a specific meaning.&amp;nbsp; A SAS FORMAT is instructions for how to display values as text.&amp;nbsp; There are numeric formats that are used with numeric values and character formats that work with character values.&lt;/P&gt;
&lt;P&gt;To go from text strings to values you use an INFORMAT.&amp;nbsp; A numeric informat will convert strings into numeric values and character informats convert strings into other strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want convert string&amp;nbsp; "20130101" into a number you can use the normal numeric informat and you will get the value&amp;nbsp;20,130,101. You have that value displayed as the string "20130101" by using the 8. format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now SAS stores dates as the number of days since 1960.&amp;nbsp; So if you want to interpret the string "20130101" as meaning the first day of the year 2013 then use the YYMMDD8. informat.&amp;nbsp; That will generate a value of&amp;nbsp;19,359.&amp;nbsp; If you want to display that in a way that a human will recognize then use any of the valid date formats.&amp;nbsp; For example you could use the DATE9. format to have it displayed as "01JAN2013" or the YYMMDD10. format to have it displayed as "2013-01-01".&amp;nbsp; To have it display like the original string use the YYMMDDN8. format.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;210   data test;
211     string='20130101';
212     number=input(string,32.);
213     date=input(string,yymmdd10.);
214     format date yymmddn8.;
215     put (_all_) (=);
216   run;

string=20130101 number=20130101 date=20130101
NOTE: The data set WORK.TEST has 1 observations and 3 variables.
&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Feb 2021 22:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/character-to-numeric/m-p/719039#M27651</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-12T22:22:03Z</dc:date>
    </item>
  </channel>
</rss>

