<?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 values to date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877023#M346460</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442325"&gt;@lovecoding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;AETRT = 22459&amp;nbsp;&lt;BR /&gt;How I can it compare with this ?&lt;/P&gt;
&lt;P&gt;AESTDTC = 2021-07-05&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is AETRT numeric or character? Is AESTDTC really a character variable, or is it numeric with a format? Please check PROC CONTENTS and determine if each of these variables is numeric or character. Let us know.&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2023 09:54:56 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-23T09:54:56Z</dc:date>
    <item>
      <title>Convert character values to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877004#M346455</link>
      <description>&lt;P&gt;AETRT = 22459&amp;nbsp;&lt;BR /&gt;How I can it compare with this ?&lt;/P&gt;&lt;P&gt;AESTDTC = 2021-07-05&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 07:40:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877004#M346455</guid>
      <dc:creator>lovecoding</dc:creator>
      <dc:date>2023-05-23T07:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character values to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877013#M346457</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442325"&gt;@lovecoding&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your question is not clear. Though I'd recommend to look at this &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2ref/p104kx3rnsddtwn1hwn1p20wgj6a.htm#:~:text=Writes%20SAS%20date%20values%20in,either%202%20or%204%20digits." target="_self"&gt;SAS Date format&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is how you can check formatted date values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format AETRT_Formatted yymmdd10.;
AETRT = 22459 ;
AETRT_Formatted = AETRT;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use PUT function if this is something you want to achieve:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AETRT_Formatted=put(AETRT,yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 08:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877013#M346457</guid>
      <dc:creator>MayurJadhav</dc:creator>
      <dc:date>2023-05-23T08:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character values to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877023#M346460</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442325"&gt;@lovecoding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;AETRT = 22459&amp;nbsp;&lt;BR /&gt;How I can it compare with this ?&lt;/P&gt;
&lt;P&gt;AESTDTC = 2021-07-05&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is AETRT numeric or character? Is AESTDTC really a character variable, or is it numeric with a format? Please check PROC CONTENTS and determine if each of these variables is numeric or character. Let us know.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 09:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877023#M346460</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-23T09:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character values to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877034#M346461</link>
      <description>&lt;P&gt;To understand more about dates and times in SAS you can read:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings15/1334-2015.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings15/1334-2015.pdf&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/Ask-the-Expert/Tips-and-Tricks-for-Working-with-Dates-and-Times-in-SAS-Q-amp-A/ta-p/813974" target="_blank"&gt;https://communities.sas.com/t5/Ask-the-Expert/Tips-and-Tricks-for-Working-with-Dates-and-Times-in-SAS-Q-amp-A/ta-p/813974&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://documentation.sas.com/doc/en/lrcon/9.4/p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/lrcon/9.4/p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;For a way to compare see the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   date1 = 22459;
   date2 = mdy(5, 7, 2021);
   days_between_1_2 = intck('day', date1, date2);
   days_between_2_1 = intck('day', date2, date1);
   formatted_date1 = date1;
   formatted_date2 = date2;
   format formatted_date1 formatted_date2 date9.;
   put date1= '|'  formatted_date1= / 
       date2= '|'  formatted_date2= / 
       'days_between date1 and date2 is ' days_between_1_2 /
       'days_between date2 and date1 is ' days_between_2_1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 10:08:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877034#M346461</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-05-23T10:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character values to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877074#M346483</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442325"&gt;@lovecoding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;AETRT = 22459&amp;nbsp;&lt;BR /&gt;How I can it compare with this ?&lt;/P&gt;
&lt;P&gt;AESTDTC = 2021-07-05&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Assuming that the variable whose name ends with the letter C is a CHARACTER variable you can convert its contents to a date value using the INPUT() function.&amp;nbsp; Looks like the string is in a style that the YYMMDD informat can read.&lt;/P&gt;
&lt;P&gt;To have the numeric value print in the same style attach the YYMMDD format to the it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  difference = aetrt - input(aestdtc,yymmdd10.);
  format aetrt yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Result&lt;/P&gt;
&lt;PRE&gt;Obs         AETRT     AESTDTC      difference

 1     2021-06-28    2021-07-05        -7

&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2023 14:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-values-to-date/m-p/877074#M346483</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-23T14:05:11Z</dc:date>
    </item>
  </channel>
</rss>

