<?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 best12 to date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913785#M360134</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;evtdate1 = input(put(evtdate,8.),yymmdd8.);
format evtdate1 date9.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 Jan 2024 13:44:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-01-31T13:44:02Z</dc:date>
    <item>
      <title>Convert best12 to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913760#M360130</link>
      <description>&lt;P&gt;Hello, I have an excel file named crspoutput that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Model&lt;/TD&gt;&lt;TD&gt;permno&lt;/TD&gt;&lt;TD&gt;evtdate&lt;/TD&gt;&lt;TD&gt;cret&lt;/TD&gt;&lt;TD&gt;car&lt;/TD&gt;&lt;TD&gt;bhar&lt;/TD&gt;&lt;TD&gt;nrets_est&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Market-Adjusted Model&lt;/TD&gt;&lt;TD&gt;10026&lt;/TD&gt;&lt;TD&gt;20170103&lt;/TD&gt;&lt;TD&gt;-0.0193&lt;/TD&gt;&lt;TD&gt;-0.02369&lt;/TD&gt;&lt;TD&gt;-0.02414&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Market-Adjusted Model&lt;/TD&gt;&lt;TD&gt;10026&lt;/TD&gt;&lt;TD&gt;20170817&lt;/TD&gt;&lt;TD&gt;-0.01316&lt;/TD&gt;&lt;TD&gt;-0.01357&lt;/TD&gt;&lt;TD&gt;-0.01389&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Market-Adjusted Model&lt;/TD&gt;&lt;TD&gt;10104&lt;/TD&gt;&lt;TD&gt;20170417&lt;/TD&gt;&lt;TD&gt;0.012635&lt;/TD&gt;&lt;TD&gt;0.000749&lt;/TD&gt;&lt;TD&gt;0.000795&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I check the formats, I see that evtdate is numeric in Best12. format with len 8, how can I convert&amp;nbsp; this to a num len 8 date9. format ?&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 11:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913760#M360130</guid>
      <dc:creator>merveayibogan</dc:creator>
      <dc:date>2024-01-31T11:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Convert best12 to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913785#M360134</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;evtdate1 = input(put(evtdate,8.),yymmdd8.);
format evtdate1 date9.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2024 13:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913785#M360134</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-31T13:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Convert best12 to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913853#M360140</link>
      <description>&lt;P&gt;Hello, thank you very much for your response. That didn't work but this worked:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data new data;&lt;BR /&gt;set olddata;&amp;nbsp;&lt;BR /&gt;if not missing(evtdate) then do;&lt;BR /&gt;year = int(evtdate / 10000);&amp;nbsp;&lt;BR /&gt;month = int((evtdate - year * 10000) / 100);&amp;nbsp;&lt;BR /&gt;day = mod(evtdate, 100);&lt;BR /&gt;put year= month= day= evtdate=;&lt;BR /&gt;new_date_variable = mdy(month, day, year);&lt;/P&gt;&lt;P&gt;format new_date_variable date9.;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 17:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913853#M360140</guid>
      <dc:creator>merveayibogan</dc:creator>
      <dc:date>2024-01-31T17:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Convert best12 to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913864#M360143</link>
      <description>&lt;P&gt;Glad you got it to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But note that&amp;nbsp;any value of EVTDATE that would could be split by your logic into separate year, month and day values that would also work when converted to a string using PUT() and then converted to a date value using INPUT().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new data;
  set olddata; 
  if not missing(evtdate) then do;
    year = int(evtdate / 10000); 
    month = int((evtdate - year * 10000) / 100); 
    day = mod(evtdate, 100);
    new_date_variable = mdy(month, day, year);
    new_date_variable2 = input(put(evtdate,z8.),yymmdd8.);
    format new_date_variable new_date_variable2  date9.;
    put  (evtdate year month day new_date_variable new_date_variable2) (=);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 18:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913864#M360143</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-31T18:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert best12 to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913876#M360148</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462592"&gt;@merveayibogan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, thank you very much for your response. That didn't work but this worked:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data new data;&lt;BR /&gt;set olddata;&amp;nbsp;&lt;BR /&gt;if not missing(evtdate) then do;&lt;BR /&gt;year = int(evtdate / 10000);&amp;nbsp;&lt;BR /&gt;month = int((evtdate - year * 10000) / 100);&amp;nbsp;&lt;BR /&gt;day = mod(evtdate, 100);&lt;BR /&gt;put year= month= day= evtdate=;&lt;BR /&gt;new_date_variable = mdy(month, day, year);&lt;/P&gt;
&lt;P&gt;format new_date_variable date9.;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code I posted worked for me. The whole idea of your code is to pull out the year, month and day and then recombine using the MDY function. Lots of steps compared to the two lines of code I showed.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 19:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-best12-to-date/m-p/913876#M360148</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-31T19:13:43Z</dc:date>
    </item>
  </channel>
</rss>

