<?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: Convert character to numeric then to date in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546524#M16813</link>
    <description>&lt;P&gt;I've attached the proc freq of the charvar&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2019 14:57:04 GMT</pubDate>
    <dc:creator>KPCklebspn</dc:creator>
    <dc:date>2019-03-27T14:57:04Z</dc:date>
    <item>
      <title>Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546511#M16810</link>
      <description>&lt;P&gt;I've got a variable whose values are either blank or a 5 digit number that SAS is reading as a character.&amp;nbsp; When I do proc contents for this var, tells me it's type char, format $5. This 5 digit number should actually correspond to a date, so I want to convert it to numeric then I can format it as a date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I've tried to do:&lt;/P&gt;&lt;P&gt;data new; set old; numVar=input(charVar, 5.); run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I do proc contents of the new dataset, it tells me that it's still a character var with len 5. Format/informat are blank. What am I doing wrong??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 14:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546511#M16810</guid>
      <dc:creator>KPCklebspn</dc:creator>
      <dc:date>2019-03-27T14:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546517#M16812</link>
      <description>&lt;P&gt;Can you provide an example of the character variable value that you want to convert?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 14:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546517#M16812</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-27T14:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546524#M16813</link>
      <description>&lt;P&gt;I've attached the proc freq of the charvar&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 14:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546524#M16813</guid>
      <dc:creator>KPCklebspn</dc:creator>
      <dc:date>2019-03-27T14:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546525#M16814</link>
      <description>&lt;P&gt;I've attached the proc freq of the charvar&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 14:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546525#M16814</guid>
      <dc:creator>KPCklebspn</dc:creator>
      <dc:date>2019-03-27T14:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546542#M16816</link>
      <description>&lt;P&gt;Do you know what date the character value eg&amp;nbsp;'42062' is to be interpreted as?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546542#M16816</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-27T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546544#M16817</link>
      <description>27Feb2015&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546544#M16817</guid>
      <dc:creator>KPCklebspn</dc:creator>
      <dc:date>2019-03-27T15:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546545#M16818</link>
      <description>&lt;P&gt;Your code works perfectly for me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old;
	charVar = '21635';
	output;
run;

proc sql;
	select * from dictionary.columns where libname="WORK" and memname="OLD";
run;

data new;
	set old;
	numVar=input(charVar, 5.);
run;

proc sql;
	select * from dictionary.columns where libname="WORK" and memname="NEW";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                                                                           Wednesday, 27 March, 2019 10:53:00 AM   1

                                                                                                                      Column
Library                                     Member                                      Column    Column    Column    Number
Name      Member Name                       Type      Column Name                       Type      Length  Position  in Table
                                                                                                                           Column
                                                                                                                           Index
Column Label         Column Format                                      Column Informat                                    Type
Order in
     Key  Extended      Not
Sequence  Type          NULL?  Precision     Scale  Transcoded?
------------------------------------------------------------------------------------------------------------------------------------
WORK      OLD                               DATA      charVar                           char           5         0         1
                                                                                                                                    
       0  char          no             0         .  yes        
                                                                                           Wednesday, 27 March, 2019 10:53:00 AM   2

                                                                                                                      Column
Library                                     Member                                      Column    Column    Column    Number
Name      Member Name                       Type      Column Name                       Type      Length  Position  in Table
                                                                                                                           Column
                                                                                                                           Index
Column Label         Column Format                                      Column Informat                                    Type
Order in
     Key  Extended      Not
Sequence  Type          NULL?  Precision     Scale  Transcoded?
------------------------------------------------------------------------------------------------------------------------------------
WORK      NEW                               DATA      charVar                           char           5         8         1
                                                                                                                                    
       0  char          no             0         .  yes        

WORK      NEW                               DATA      numVar                            num            8         0         2
                                                                                                                                    
       0  num           no             0         .  yes        
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546545#M16818</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2019-03-27T15:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character to numeric then to date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546562#M16820</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/141326"&gt;@KPCklebspn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've attached the proc freq of the charvar&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Looks like a typical Excel date to SAS date conversion. If your data started in Excel then the issue is how you brought the data into SAS, and possibly what has been done since.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, did this data start in Excel? If so please describe how you brought it into SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-character-to-numeric-then-to-date/m-p/546562#M16820</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-27T15:44:34Z</dc:date>
    </item>
  </channel>
</rss>

