<?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 Convert string date to date value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855178#M338012</link>
    <description>&lt;P&gt;I have a variable Enrollment_month - type character, length 8 with value ex:FEB2022. I want to convert this into date format as 20220201. Please help&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2023 19:13:10 GMT</pubDate>
    <dc:creator>cm3</dc:creator>
    <dc:date>2023-01-23T19:13:10Z</dc:date>
    <item>
      <title>Convert string date to date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855178#M338012</link>
      <description>&lt;P&gt;I have a variable Enrollment_month - type character, length 8 with value ex:FEB2022. I want to convert this into date format as 20220201. Please help&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 19:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855178#M338012</guid>
      <dc:creator>cm3</dc:creator>
      <dc:date>2023-01-23T19:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string date to date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855182#M338014</link>
      <description>&lt;P&gt;Since your notation fits most of the DATE9 informat, conversion is easy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(enrollment_month=_em));
format enrollment_month yymmddn8.;
enrollment_month = input(cats("01",_em),date9.);
drop _em;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS I changed your subject line. "Hi" is not descriptive and only makes you look silly.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 19:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855182#M338014</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-23T19:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Hi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855188#M338015</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Want;
  Enrollment_month = 'FEB2022';
  Enrollment_date = input('01' !! Enrollment_month, date9.);
  format Enrollment_date yymmddn8.;
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2023 19:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855188#M338015</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-01-23T19:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string date to date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855192#M338016</link>
      <description>your solution worked , thank you.&lt;BR /&gt;Thanks for updating the title, it was bit confusing in mobile and I missed it</description>
      <pubDate>Mon, 23 Jan 2023 19:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855192#M338016</guid>
      <dc:creator>cm3</dc:creator>
      <dc:date>2023-01-23T19:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Hi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855193#M338017</link>
      <description>Also I was wondering how would we convert if enrollment_month is type date with same value?? Pls confirm</description>
      <pubDate>Mon, 23 Jan 2023 19:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855193#M338017</guid>
      <dc:creator>cm3</dc:creator>
      <dc:date>2023-01-23T19:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855201#M338025</link>
      <description>&lt;P&gt;If it is already a SAS date value, you only need to change the assigned format, e.g. with PROC DATASETS for the dataset, or with a FORMAT statement (or FORMAT= option in PROC SQL) wherever needed.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 20:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855201#M338025</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-23T20:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Hi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855208#M338030</link>
      <description>&lt;P&gt;"If&amp;nbsp;&lt;SPAN&gt;enrollment_month is type date with same value" - A numeric variable can't contain the same value as "FEB2022" as that is character data. The closest you can get is this, where you define it as a date based on 01 Feb 2022:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Want;
  Enrollment_month = '01FEB2022'd;
  Enrollment_date = Enrollment_month; 
  format Enrollment_month date9. Enrollment_date yymmddn8.;
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2023 20:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855208#M338030</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-01-23T20:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Hi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855243#M338038</link>
      <description>&lt;P&gt;PS there is no&amp;nbsp;&lt;U&gt;type&lt;/U&gt; "date" in SAS. SAS has only two types of variables, character and numeric.&lt;/P&gt;
&lt;P&gt;Dates are stored in numeric variables, as counts of days with 1960-01-01 as day zero, and with a proper format assigned to make the raw value human-readable.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 21:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855243#M338038</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-23T21:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string date to date value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855286#M338061</link>
      <description>Also could try MONYY. informat.&lt;BR /&gt;&lt;BR /&gt;data Want;&lt;BR /&gt;  Enrollment_month = 'FEB2022';&lt;BR /&gt;  Enrollment_date = input(Enrollment_month, monyy9.);&lt;BR /&gt;  format Enrollment_date yymmddn8.;&lt;BR /&gt;  put _all_;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 24 Jan 2023 05:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-string-date-to-date-value/m-p/855286#M338061</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-01-24T05:24:43Z</dc:date>
    </item>
  </channel>
</rss>

