<?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 Converting varaiable type from character to numeric in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-varaiable-type-from-character-to-numeric/m-p/786122#M32181</link>
    <description>My Data has the following date values in character variable type&lt;BR /&gt;Date&lt;BR /&gt;2013/12&lt;BR /&gt;2014/01&lt;BR /&gt;2014/02&lt;BR /&gt;2014/02&lt;BR /&gt;2012/06&lt;BR /&gt;&lt;BR /&gt;How should I convert the variable type to numeric?</description>
    <pubDate>Wed, 15 Dec 2021 08:59:14 GMT</pubDate>
    <dc:creator>Dg112</dc:creator>
    <dc:date>2021-12-15T08:59:14Z</dc:date>
    <item>
      <title>Converting varaiable type from character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-varaiable-type-from-character-to-numeric/m-p/786122#M32181</link>
      <description>My Data has the following date values in character variable type&lt;BR /&gt;Date&lt;BR /&gt;2013/12&lt;BR /&gt;2014/01&lt;BR /&gt;2014/02&lt;BR /&gt;2014/02&lt;BR /&gt;2012/06&lt;BR /&gt;&lt;BR /&gt;How should I convert the variable type to numeric?</description>
      <pubDate>Wed, 15 Dec 2021 08:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-varaiable-type-from-character-to-numeric/m-p/786122#M32181</guid>
      <dc:creator>Dg112</dc:creator>
      <dc:date>2021-12-15T08:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Converting varaiable type from character to numeric</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-varaiable-type-from-character-to-numeric/m-p/786123#M32182</link>
      <description>&lt;P&gt;Since you cannot change the type of a variable, you have to create a new one, which is done by doing the "rename-convert-drop" dance:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date $7.;
datalines;
2013/12
2014/01
2014/02
2014/02
2012/06
;

data want;
set have (rename=(date=_date));
format date yymms7.;
date = input(compress(_date,"/"),yymmn6.);
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(SAS will automatically assume the first day of the month for the raw date values)&lt;/P&gt;
&lt;P&gt;Alternatively, you can add the day yourself and use a complete date informat:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(date=_date));
format date yymms7.;
date = input(_date!!"/01",yymmdd10.);
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can use the same method when initially bringing the data into SAS, which depends on the type of your data source.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 09:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-varaiable-type-from-character-to-numeric/m-p/786123#M32182</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-15T09:11:09Z</dc:date>
    </item>
  </channel>
</rss>

