<?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: Get the previous year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697598#M213217</link>
    <description>&lt;P&gt;If you used the YEAR() function, then the numeric value can be used in a simple subtraction.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Nov 2020 13:06:11 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-11-09T13:06:11Z</dc:date>
    <item>
      <title>Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697577#M213203</link>
      <description>&lt;P&gt;I have variable named date with value&amp;nbsp;&lt;/P&gt;&lt;P&gt;date=2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i want to get the previous year based on the value in the date column i.e 2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do i get that.??&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 11:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697577#M213203</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2020-11-09T11:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697578#M213204</link>
      <description>&lt;P&gt;This does noot seem to be a date varaible? Rather a year variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, then simply subtract 1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   date1 = 2020;
   date2 = date1 - 1;

   put date1 = / date2 =;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2020 11:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697578#M213204</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-09T11:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697581#M213205</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190967"&gt;@Son_Of_Krypton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have variable named date with value&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date=2020&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and i want to get the previous year based on the value in the date column i.e 2019.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how do i get that.??&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date - 1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Nov 2020 11:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697581#M213205</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-09T11:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697594#M213214</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190967"&gt;@Son_Of_Krypton&lt;/a&gt;&amp;nbsp; Are you seriously asking a subtraction question? Or are you trying to mean previous as LAG, as in previous value read in queue from the previous record in a dataset?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 12:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697594#M213214</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-11-09T12:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697595#M213215</link>
      <description>no i am having date like 09NOV2020 and then i extracted year from it i.e 2020 based on this year i want previous year in another variable&lt;BR /&gt;&lt;BR /&gt;I know that it can be done via intnx on date 09NOV2020 like&lt;BR /&gt;&lt;BR /&gt;Test=intnx('Year','09NOV2020'd,-1);&lt;BR /&gt;Test2=Year(Test);&lt;BR /&gt;&lt;BR /&gt;but is it possible to do on year 2020 only.??</description>
      <pubDate>Mon, 09 Nov 2020 13:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697595#M213215</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2020-11-09T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697598#M213217</link>
      <description>&lt;P&gt;If you used the YEAR() function, then the numeric value can be used in a simple subtraction.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 13:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697598#M213217</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-09T13:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697603#M213220</link>
      <description>&lt;P&gt;Right, I am afraid I am still not clear with your objective.&lt;/P&gt;
&lt;P&gt;You mentioned you have a date variable with a value&amp;nbsp;&lt;SPAN&gt;09NOV2020&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Extracting the YEAR value from the date value would indeed give you 2020. And then just like other's suggestion it should be year(date)-1 however this will give 2019. So when your "year" is already 2020, I would think you do not need to subtract unless you want 2019.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am i mistaken, or is it the damn starbucks coffee not strong enough?hmm&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 13:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697603#M213220</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-11-09T13:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get the previous year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697660#M213242</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year(dateVariable) = 2020 then Test=intnx('Year', dateVariable, -1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Replace the dateVariable with the name of your variable and you're fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190967"&gt;@Son_Of_Krypton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;no i am having date like 09NOV2020 and then i extracted year from it i.e 2020 based on this year i want previous year in another variable&lt;BR /&gt;&lt;BR /&gt;I know that it can be done via intnx on date 09NOV2020 like&lt;BR /&gt;&lt;BR /&gt;Test=intnx('Year','09NOV2020'd,-1);&lt;BR /&gt;Test2=Year(Test);&lt;BR /&gt;&lt;BR /&gt;but is it possible to do on year 2020 only.??&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 16:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-previous-year/m-p/697660#M213242</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-09T16:32:45Z</dc:date>
    </item>
  </channel>
</rss>

