<?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: To get only Year from DATETIME20. format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468612#M119721</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   dt="23MAY2013:00:00:00"dt;
   year=year(datepart(dt));
   put year=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Jun 2018 08:04:59 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-06-08T08:04:59Z</dc:date>
    <item>
      <title>To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468610#M119719</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;I need your help in year format.&lt;/P&gt;&lt;P&gt;I have a data set which has got commencement_dt as 23MAY2013:00:00:00&amp;nbsp;which is in DATETIME20. format, from the same commencement_dt i want to get only year. Is there a way where i can get only year format or by creating another variable only for year to appear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 08:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468610#M119719</guid>
      <dc:creator>BIDD</dc:creator>
      <dc:date>2018-06-08T08:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468611#M119720</link>
      <description>&lt;P&gt;Use the datepart() and year() functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input commencement_dt :datetime20.;
format commencement_dt datetime20.;
cards;
23MAY2013:00:00:00
;
run;

data want;
set have;
commencement_year = year(datepart(commencement_dt));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0h7yad9hjgydgn1ijrkvzq8s7jy.htm" target="_self"&gt;use the DTYEAR format&lt;/A&gt; to display just the year from a datetime value in SAS -- no need to create a different variable.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 13:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468611#M119720</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-29T13:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468612#M119721</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   dt="23MAY2013:00:00:00"dt;
   year=year(datepart(dt));
   put year=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 08:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468612#M119721</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-06-08T08:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468618#M119726</link>
      <description>&lt;P&gt;great, thanks for your help. it worked&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 08:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468618#M119726</guid>
      <dc:creator>BIDD</dc:creator>
      <dc:date>2018-06-08T08:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468623#M119729</link>
      <description>&lt;P&gt;thanks for that, it worked&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 08:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468623#M119729</guid>
      <dc:creator>BIDD</dc:creator>
      <dc:date>2018-06-08T08:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468625#M119731</link>
      <description>&lt;P&gt;we can use &lt;STRONG&gt;Year()&lt;/STRONG&gt; fun to extract the year from sas date value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data &amp;nbsp;&amp;nbsp; Demo;&lt;/P&gt;&lt;P&gt;Var1='21feb2002:22:23:00'd;&lt;/P&gt;&lt;P&gt;var2=year( var1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 09:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468625#M119731</guid>
      <dc:creator>katkarparam</dc:creator>
      <dc:date>2018-06-08T09:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468626#M119732</link>
      <description>Hi, thanks for that... My requirement is;i have over 1000 records on&lt;BR /&gt;commencement_date variable, if you can provide me the solution to change at&lt;BR /&gt;one shot for all rather than one date.. It would be great ...Sorry I forgot&lt;BR /&gt;to mention that in the post&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Jun 2018 09:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468626#M119732</guid>
      <dc:creator>BIDD</dc:creator>
      <dc:date>2018-06-08T09:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468630#M119734</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188222"&gt;@katkarparam&lt;/a&gt; only wanted to show that SAS accepts any longer string as a date literal, as long as the start is a SAS date:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
x1 = '01jan2018xxxxxxxxxxx'd;
format x1 yymmddd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For existing data, use a data step similar to mine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 09:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468630#M119734</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-08T09:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468631#M119735</link>
      <description>Will check on Monday thanks for ur help...&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Jun 2018 09:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468631#M119735</guid>
      <dc:creator>BIDD</dc:creator>
      <dc:date>2018-06-08T09:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468633#M119737</link>
      <description>&lt;P&gt;Yes, you are right. data test;&lt;/P&gt;&lt;P&gt;x1 = '01jan2018xxxxxxxxxxx'd;&lt;/P&gt;&lt;P&gt;format x1 yymmddd10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output dataset contain&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; x1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2018-01-01&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 09:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468633#M119737</guid>
      <dc:creator>katkarparam</dc:creator>
      <dc:date>2018-06-08T09:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468645#M119739</link>
      <description>I will let you know..&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Jun 2018 11:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/468645#M119739</guid>
      <dc:creator>katkarparam</dc:creator>
      <dc:date>2018-06-08T11:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: To get only Year from DATETIME20. format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/685104#M207734</link>
      <description>&lt;P&gt;Realize this is a while following the original post, but I got this to work in a select proc sql statement with an existing datetime20. formatted variable in a table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;year(datepart(table_cases.item_date)) as ITEM_YEAR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's a numerical variable, but it worked.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 20:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-get-only-Year-from-DATETIME20-format/m-p/685104#M207734</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2020-09-18T20:41:02Z</dc:date>
    </item>
  </channel>
</rss>

