<?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 How do I convert a date string without hyphens to a date value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900020#M355705</link>
    <description>&lt;P&gt;I am trying to convert a date string written without hyphens into a date value. I can do so using the INPUT function if the date is written as "2001-01-01" by calling INPUT("2001-01-01", YYMMDD10.) However, I cannot do the same using YYMMDDN8. or any other format that does not include hyphens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT("2001-01-01", YYMMDD10.) = 14976&amp;nbsp; *Correct!&lt;/P&gt;&lt;P&gt;INPUT("20010101", YYMMDDN8.) = 20010101&amp;nbsp; &amp;nbsp;*Incorrect&lt;/P&gt;&lt;P&gt;INPUT("2001.01.01", YYMMDDP8.) = .&amp;nbsp; &amp;nbsp;*Incorrect&lt;/P&gt;&lt;P&gt;INPUT("2001 01 01", YYMMDDB8.) = .&amp;nbsp; &amp;nbsp;*Incorrect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong!?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Writing a date with hyphens is causing issues when I write a macro to convert a date string into a date value, so I cannot write the date string that way.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 18:29:47 GMT</pubDate>
    <dc:creator>mhamiltonsmith</dc:creator>
    <dc:date>2023-10-25T18:29:47Z</dc:date>
    <item>
      <title>How do I convert a date string without hyphens to a date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900020#M355705</link>
      <description>&lt;P&gt;I am trying to convert a date string written without hyphens into a date value. I can do so using the INPUT function if the date is written as "2001-01-01" by calling INPUT("2001-01-01", YYMMDD10.) However, I cannot do the same using YYMMDDN8. or any other format that does not include hyphens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT("2001-01-01", YYMMDD10.) = 14976&amp;nbsp; *Correct!&lt;/P&gt;&lt;P&gt;INPUT("20010101", YYMMDDN8.) = 20010101&amp;nbsp; &amp;nbsp;*Incorrect&lt;/P&gt;&lt;P&gt;INPUT("2001.01.01", YYMMDDP8.) = .&amp;nbsp; &amp;nbsp;*Incorrect&lt;/P&gt;&lt;P&gt;INPUT("2001 01 01", YYMMDDB8.) = .&amp;nbsp; &amp;nbsp;*Incorrect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong!?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Writing a date with hyphens is causing issues when I write a macro to convert a date string into a date value, so I cannot write the date string that way.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 18:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900020#M355705</guid>
      <dc:creator>mhamiltonsmith</dc:creator>
      <dc:date>2023-10-25T18:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert a date string without hyphens to a date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900021#M355706</link>
      <description>&lt;P&gt;There is no informat&amp;nbsp;&lt;SPAN&gt;YYMMDDN8. or&amp;nbsp;YYMMDDP8. or&amp;nbsp;YYMMDDB8.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    date_without_hyphens='20010101';
    date_with_hyphens='2001-01-01';
    date_with_periods='2001.01.01';
    date_without_hyphens2=input(date_without_hyphens,yymmdd8.);
    date_with_hypens2=input(date_with_hyphens,yymmdd10.);
    date_with_periods2=input(date_with_periods,yymmdd10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 18:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900021#M355706</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-25T18:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert a date string without hyphens to a date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900040#M355715</link>
      <description>&lt;P&gt;Informat YYMMDD10. works for all your date patterns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  infile datalines truncover;
  input dt_string $20.;
  format dt_sas date9.;
  dt_sas=input(dt_string,yymmdd10.);
  datalines;
2001-01-01
20010101
2001.01.01
2001 01 01
;

proc print data=demo;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1698277766908.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89088iC2A46938FD13C685/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1698277766908.png" alt="Patrick_0-1698277766908.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 23:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900040#M355715</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-25T23:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert a date string without hyphens to a date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900053#M355717</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Informat YYMMDD10. works for all your date patterns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  infile datalines truncover;
  input dt_string $20.;
  format dt_sas date9.;
  dt_sas=input(dt_string,yymmdd10.);
  datalines;
2001-01-01
20010101
2001.01.01
2001 01 01
;

proc print data=demo;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1698277766908.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89088iC2A46938FD13C685/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1698277766908.png" alt="Patrick_0-1698277766908.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Exactly.&amp;nbsp; The INPUT() function does not care if the WIDTH you used in the INFORMAT is larger than the LENGTH of the string you are reading.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 01:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-convert-a-date-string-without-hyphens-to-a-date-value/m-p/900053#M355717</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-26T01:48:15Z</dc:date>
    </item>
  </channel>
</rss>

