<?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 ((int)year,(int)month,(int)day) to Datetime [duplicate] in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292693#M60812</link>
    <description>i tried to solve the problem but it showing error message&lt;BR /&gt;format DOB yymmddd10.;&lt;BR /&gt;----------&lt;BR /&gt;48&lt;BR /&gt;ERROR 48-59: The format $YYMMDDD was not found or could not be loaded.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 19 Aug 2016 09:59:59 GMT</pubDate>
    <dc:creator>gowtham112</dc:creator>
    <dc:date>2016-08-19T09:59:59Z</dc:date>
    <item>
      <title>convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292675#M60806</link>
      <description>&lt;P&gt;I have a data table that stores each year, month and day value as ints:&lt;/P&gt;&lt;PRE class="lang-sql prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;year &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; month &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; day&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2009&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;   &lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt; 
&lt;SPAN class="lit"&gt;2008&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;12&lt;/SPAN&gt;   &lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;2&lt;/SPAN&gt;
&lt;SPAN class="lit"&gt;2007&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;   &lt;SPAN class="lit"&gt;5&lt;/SPAN&gt;   &lt;SPAN class="pun"&gt;|&lt;/SPAN&gt;  &lt;SPAN class="lit"&gt;5&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I need to convert it to datetime value, because I need to use it in a datetime between operation. How could I do this?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 08:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292675#M60806</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-08-19T08:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292678#M60807</link>
      <description>&lt;P&gt;Use the dhms() and mdy() functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;wantedvalue = dhms(mdy(month,day2009,year),0,0,0);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 08:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292678#M60807</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-19T08:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292681#M60808</link>
      <description>&lt;P&gt;Hi KurtBremser,&lt;BR /&gt;&lt;BR /&gt;Thanks for giving reply,Actually question was wrongly posted, Below i posted question&lt;BR /&gt;&lt;BR /&gt;Year Month Day&lt;BR /&gt;2009 01 01&lt;BR /&gt;2008 12 02&lt;BR /&gt;2007 05 05&lt;BR /&gt;&lt;BR /&gt;These values are in different columns, so i want to&lt;BR /&gt;combine these variables to get date value in character format&lt;BR /&gt;(2009-01-01&lt;BR /&gt;2008-12-02&lt;BR /&gt;2001-05-05).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 09:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292681#M60808</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-08-19T09:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292688#M60810</link>
      <description>&lt;P&gt;The leading zeros make me believe that you already have the values stored in variables of type character.&lt;/P&gt;
&lt;P&gt;If this is so, a simple concatenation will do the trick:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newvar = year !! '-' !! month !! '-' !! day;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If this produces unwanted blanks (because the variables are defined longer thatn necessary), use the strip() function to get rid of them.&lt;/P&gt;
&lt;P&gt;If your values are actually stored as numbers, this will create the same character value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newvar = put(mdy(year,day,month),yymmddd10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The third "d" in the format specifies the separator character (dash) &lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 09:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292688#M60810</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-19T09:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292691#M60811</link>
      <description>thank you for solution ..</description>
      <pubDate>Fri, 19 Aug 2016 09:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292691#M60811</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-08-19T09:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292693#M60812</link>
      <description>i tried to solve the problem but it showing error message&lt;BR /&gt;format DOB yymmddd10.;&lt;BR /&gt;----------&lt;BR /&gt;48&lt;BR /&gt;ERROR 48-59: The format $YYMMDDD was not found or could not be loaded.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Aug 2016 09:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292693#M60812</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-08-19T09:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292694#M60813</link>
      <description>&lt;P&gt;SAS complains about a missing $.... format. This means that you tried to apply the &lt;U&gt;numeric&lt;/U&gt; format YYMMDDD10. to a &lt;U&gt;character&lt;/U&gt; variable. In such a case SAS assumes that you mistyped and adds the $ for a character format on its own. This is then not found.&lt;/P&gt;
&lt;P&gt;SAS date and datetime formats must be applied to &lt;U&gt;numeric&lt;/U&gt; variables that hold date (days since 1960-01-01) or datetime (seconds since 1960-01-01:00:00:00) values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 10:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292694#M60813</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-19T10:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292698#M60814</link>
      <description>&lt;P&gt;Actually i want the variable in charcter format with requried date format.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 10:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292698#M60814</guid>
      <dc:creator>gowtham112</dc:creator>
      <dc:date>2016-08-19T10:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292701#M60815</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/93916"&gt;@gowtham112&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Actually i want the variable in charcter format with requried date format.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is not possible. To apply a date/datetime format, the variable MUST be numeric.&lt;/P&gt;
&lt;P&gt;But you can use the format to convert the value in the numeric variable to a character value, and store that in a separate character variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format date_num yymmddd10.;
date_num = date();
date_char = put(date_num, yymmddd10.);
date_num_raw = date_num;
run;

proc print noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;result:&lt;/P&gt;
&lt;PRE&gt;                             date_
  date_num    date_char     num_raw

2016-08-19    2016-08-19     20685 
&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 11:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-int-year-int-month-int-day-to-Datetime-duplicate/m-p/292701#M60815</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-19T11:16:11Z</dc:date>
    </item>
  </channel>
</rss>

