<?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: How to extract year and month from date in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339843#M77566</link>
    <description>&lt;P&gt;Can I create a new column year within proc sql?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select input(thedate,yymmdd10.) as myyear&lt;BR /&gt;from mytable;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this but doesn't seem to work.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 01:08:47 GMT</pubDate>
    <dc:creator>afiqcjohari</dc:creator>
    <dc:date>2017-03-10T01:08:47Z</dc:date>
    <item>
      <title>How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339583#M77494</link>
      <description>&lt;P&gt;I have date variables in the form of YYYY-MM-DD, stored in tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I extract the Year?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I just want to do a simple SQL&amp;nbsp;&lt;/P&gt;&lt;P&gt;such as, select * from table where YEAR(date) = 2017;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 10:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339583#M77494</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-09T10:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339584#M77495</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;the function you are looking for is year() as you guessed correctly, but your data has to be in&lt;/P&gt;
&lt;P&gt;a date format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
format dt yymmdd10.;
input dt yymmdd10.;
datalines;
2016-05-21
2017-08-12
2014-03-02
;
run;

data want;
set have;
where year(dt)=2017;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Edit: If you have strings instead :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
where year(input(dt,yymmdd10.))=2017;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 10:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339584#M77495</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-03-09T10:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339585#M77496</link>
      <description>&lt;P&gt;Are you sure its a SAS numeric date, i.e. it is a number if you remove the format. &amp;nbsp;If so then year(), if it is character which I suspect, then just use:&lt;/P&gt;
&lt;P&gt;where scan(date,1,"-")="2017";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 10:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339585#M77496</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-09T10:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339843#M77566</link>
      <description>&lt;P&gt;Can I create a new column year within proc sql?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select input(thedate,yymmdd10.) as myyear&lt;BR /&gt;from mytable;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this but doesn't seem to work.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 01:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339843#M77566</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-10T01:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339844#M77567</link>
      <description>&lt;P&gt;The date is in this format&amp;nbsp;YYMMDD10.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 01:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/339844#M77567</guid>
      <dc:creator>afiqcjohari</dc:creator>
      <dc:date>2017-03-10T01:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/393469#M94756</link>
      <description>Hi , I have input file having year ( let's say 2015 to 2017 YYYY) .&lt;BR /&gt;I am trying to fetch system year ( year(today())&lt;BR /&gt;And then compare year from input file to fetched year.&lt;BR /&gt;If matches , those rows should come in output.&lt;BR /&gt;&lt;BR /&gt;If comparison for years is not working ..Have tried reading input year in chat..Integer both..But nothing working.&lt;BR /&gt;Can some one please help..Urgent !</description>
      <pubDate>Wed, 06 Sep 2017 09:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/393469#M94756</guid>
      <dc:creator>Singla14</dc:creator>
      <dc:date>2017-09-06T09:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/393480#M94762</link>
      <description>&lt;P&gt;This question is answered and closed. &amp;nbsp;Please start a new thread providing example data in the form of a datastep and what the output should look like.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 09:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/393480#M94762</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-09-06T09:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract year and month from date in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/468647#M119740</link>
      <description>&lt;P&gt;Do you have another solution&amp;nbsp;&lt;SPAN&gt;to change observation value at&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;one shot for all rather than one by one. suppose i have billions of record...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 11:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-year-and-month-from-date-in-SAS/m-p/468647#M119740</guid>
      <dc:creator>katkarparam</dc:creator>
      <dc:date>2018-06-08T11:16:34Z</dc:date>
    </item>
  </channel>
</rss>

