<?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 SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric/m-p/838518#M331537</link>
    <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data have;
   input dob $;
datalines;
07/1980
03/1978
10/1982
;

data want;
  set have;
  dobnum = input(dob,anydtdte.);
  format dobnum mmyys7.;
  /*redundant*/
  month = put(dobnum,monname. -L);
  year = year(dobnum);
run;&lt;/PRE&gt;
&lt;P&gt;The Input creates a date value using a very flexible approach for many date layouts. In this case it will assume that the day of the month is 1.&lt;/P&gt;
&lt;P&gt;The Month and Year are redundant because you can get them easily from the Dobnum variable by applying a format if needed. The -L in the Put is the left justify the value so that there aren't any leading spaces in the month text.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Oct 2022 20:54:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-10-13T20:54:03Z</dc:date>
    <item>
      <title>character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric/m-p/838513#M331535</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a dataset&lt;/P&gt;&lt;P&gt;DOB (character)&lt;/P&gt;&lt;P&gt;07/1980&lt;/P&gt;&lt;P&gt;03/1978&lt;/P&gt;&lt;P&gt;10/1982&lt;/P&gt;&lt;P&gt;I want this to change to numeric. And a separate month and year column added.&lt;/P&gt;&lt;P&gt;DOB(numeric)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Month&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year&lt;/P&gt;&lt;P&gt;07/1980&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;July&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1980&lt;/P&gt;&lt;P&gt;03/1978&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;March&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1978&lt;/P&gt;&lt;P&gt;10/1982&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; October&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1982&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;</description>
      <pubDate>Thu, 13 Oct 2022 20:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric/m-p/838513#M331535</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2022-10-13T20:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-numeric/m-p/838518#M331537</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data have;
   input dob $;
datalines;
07/1980
03/1978
10/1982
;

data want;
  set have;
  dobnum = input(dob,anydtdte.);
  format dobnum mmyys7.;
  /*redundant*/
  month = put(dobnum,monname. -L);
  year = year(dobnum);
run;&lt;/PRE&gt;
&lt;P&gt;The Input creates a date value using a very flexible approach for many date layouts. In this case it will assume that the day of the month is 1.&lt;/P&gt;
&lt;P&gt;The Month and Year are redundant because you can get them easily from the Dobnum variable by applying a format if needed. The -L in the Put is the left justify the value so that there aren't any leading spaces in the month text.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 20:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-numeric/m-p/838518#M331537</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-13T20:54:03Z</dc:date>
    </item>
  </channel>
</rss>

