<?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: How to change a character variable to a numeric date variable in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691391#M37299</link>
    <description>&lt;P&gt;data example;&lt;BR /&gt;z = '2017-10-26T00:00:00';&lt;BR /&gt;x = input(z,yymmdd10.);&lt;BR /&gt;format x date7.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;specifying a length on the input will only read that number of characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the future it may help to post example data as text, not pictures. It is very hard to write code against pictures. It would also be a good idea to post actual code attempted.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Oct 2020 20:36:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-10-13T20:36:43Z</dc:date>
    <item>
      <title>How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691386#M37296</link>
      <description>&lt;P&gt;I'm on a problem that is asking me to extract the date from a character variable(&lt;EM&gt;&lt;STRONG&gt;RegisteredDate&lt;/STRONG&gt;&lt;/EM&gt;) and change it to a numeric date variable with the &lt;STRONG&gt;DATE7&lt;/STRONG&gt; format.&lt;/P&gt;&lt;P&gt;I need to create a new computed column called &lt;EM&gt;&lt;STRONG&gt;RegisteredDate_New&lt;/STRONG&gt;&lt;/EM&gt;. Which functions should I use to do this?&lt;/P&gt;&lt;P&gt;I've been trying the &lt;STRONG&gt;DATE()&lt;/STRONG&gt;, and&lt;STRONG&gt; INPUT()&lt;/STRONG&gt; functions. Please let me know which functions would work for this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;*This is the code from the Query builder of the Data file I'm working on.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Where would I insert the Code? Again I'm a noob, so I really appreciate the help. Thank you.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE WORK.QUERY_FOR_FORECLOSURES AS 
   SELECT t1.APN, 
          t1.RegisteredDate, 
          t1.PropertyType, 
          t1.PropertyAddress, 
          t1.CouncilDistrict, 
          t1.Lender, 
          t1.LenderContact, 
          t1.LenderPhone, 
          t1.PropertyManagement, 
          t1.PropertyManagementContact, 
          t1.PropertyManagementAddress, 
          t1.PropertyMgmtContactPhone
      FROM WORK.FORECLOSURES t1;
QUIT;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 00:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691386#M37296</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-14T00:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691387#M37297</link>
      <description>&lt;P&gt;Try reading it in as ANYDTDTM17. (check the length) and then using DATEPART to get the date portion of the Date-Time value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 20:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691387#M37297</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T20:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691391#M37299</link>
      <description>&lt;P&gt;data example;&lt;BR /&gt;z = '2017-10-26T00:00:00';&lt;BR /&gt;x = input(z,yymmdd10.);&lt;BR /&gt;format x date7.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;specifying a length on the input will only read that number of characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the future it may help to post example data as text, not pictures. It is very hard to write code against pictures. It would also be a good idea to post actual code attempted.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 20:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691391#M37299</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-13T20:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691394#M37300</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s code should do you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're reading in text, here's a ready-made example using DATEPART().&amp;nbsp; Results are below the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data	Date_Data;
	FORMAT	RegisteredDate		DATETIME17.;
	FORMAT	RegisteredDateNew	DATE9.;
	
	INPUT	RegisteredDate	:	ANYDTDTM17.;

	RegisteredDateNew		=	DATEPART(RegisteredDate);
DATALINES;
2017-10-26T00:00:00
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1602621695397.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50637i34F588E8D7DCBF4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1602621695397.png" alt="jimbarbour_0-1602621695397.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 20:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691394#M37300</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T20:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691414#M37303</link>
      <description>So when you edit the code, are you using Sas studio? Like most answers I get start with “data _;” and end with “run;” that wouldn’t work/ be necessary in the querybuilder/Computer Column of SAS EG . Sorry I’m very new to all of this.</description>
      <pubDate>Tue, 13 Oct 2020 21:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691414#M37303</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-13T21:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691416#M37304</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/349329"&gt;@BrockJarvie&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using Enterprise Guide 8.2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you hold down the Ctrl key on your keyboard and press "N" while continuing to hold down the Ctrl key, a Program window should open up.&amp;nbsp; You can just cut and paste in the code I posted above and try running it by either clicking the little SAS running man icon or by pressing F3.&amp;nbsp; Play with the code a bit.&amp;nbsp; See what it does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a lot more to EG than Query Builder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 21:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691416#M37304</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-13T21:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691439#M37307</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/349329"&gt;@BrockJarvie&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like the below.&amp;nbsp; I'm doing this from memory.&amp;nbsp; I think the FORMAT comes after the AS, but try it the other way around if it doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE WORK.QUERY_FOR_FORECLOSURES AS 
   SELECT t1.APN, 
          DATEPART(INPUT(t1.RegisteredDate, ANYDTDTM19.)) AS RegisteredDateNew  FORMAT=DATE7.,
          t1.PropertyType, 
          t1.PropertyAddress, 
          t1.CouncilDistrict, 
          t1.Lender, 
          t1.LenderContact, 
          t1.LenderPhone, 
          t1.PropertyManagement, 
          t1.PropertyManagementContact, 
          t1.PropertyManagementAddress, 
          t1.PropertyMgmtContactPhone
      FROM WORK.FORECLOSURES t1;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Oct 2020 01:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691439#M37307</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-14T01:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a character variable to a numeric date variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691441#M37308</link>
      <description>&lt;P&gt;Thank You! That worked like a charm.&lt;/P&gt;&lt;P&gt;Again I appreciate the help!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2020 02:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-change-a-character-variable-to-a-numeric-date-variable/m-p/691441#M37308</guid>
      <dc:creator>BrockJarvie</dc:creator>
      <dc:date>2020-10-14T02:19:32Z</dc:date>
    </item>
  </channel>
</rss>

