<?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 can I extract the year from a sas date variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292731#M270121</link>
    <description>&lt;P&gt;You are missing a set statement to set an input dataset. &amp;nbsp;That step has no data:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;data orpwork;&lt;BR /&gt;  set &amp;lt;yourdataset&amp;gt;;
  tx_year=year(orp_tx_start);
run;&lt;/PRE&gt;
&lt;P&gt;Also note that orp_tx_start needs to be a numeric SAS datetime.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2016 14:14:47 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-08-19T14:14:47Z</dc:date>
    <item>
      <title>How can I extract the year from a sas date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292721#M270120</link>
      <description>&lt;P&gt;I have a variable that is in SAS date formate and I want to extract just the year from this into a new variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code but I'm not sure what I'm doing wrong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data orpwork;
tx_year=year(orp_tx_start);
run;&lt;/PRE&gt;&lt;P&gt;How do I extract the year from my date variable into a new variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 13:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292721#M270120</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-08-19T13:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract the year from a sas date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292731#M270121</link>
      <description>&lt;P&gt;You are missing a set statement to set an input dataset. &amp;nbsp;That step has no data:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;data orpwork;&lt;BR /&gt;  set &amp;lt;yourdataset&amp;gt;;
  tx_year=year(orp_tx_start);
run;&lt;/PRE&gt;
&lt;P&gt;Also note that orp_tx_start needs to be a numeric SAS datetime.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292731#M270121</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-19T14:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract the year from a sas date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292735#M270122</link>
      <description>&lt;P&gt;The short answer here is: use the year() function. But you did that and still you have this question. Did something go wrong? Please provide us your logs for additionsal info.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I can see in your code is that the datastep lacks an input. We would expect a SET or an INFILE statement. That inoput should provide variable orp_tx_start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 14:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292735#M270122</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-08-19T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract the year from a sas date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292752#M270123</link>
      <description>&lt;P&gt;Search your online documentation for SAS functions involving Date and time. There are many functions to extract and manipulate the data. And sometimes you don't need to "extract" at all.&lt;/P&gt;
&lt;P&gt;If you data is a date then you can display and use only the year value for most analyis by assigning a format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data =yourdatasetname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var orp_tx_start;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;format orp_tx_start year4.;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will display the value as a 4 digit year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other formats can display week of the year, year and quarter, year and month, day of the week, calendar quarter, month.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 15:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-the-year-from-a-sas-date-variable/m-p/292752#M270123</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-19T15:05:37Z</dc:date>
    </item>
  </channel>
</rss>

