<?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: Calculate month and quarter based on year and week in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687214#M24513</link>
    <description>Thank you Tom! It works perfectly.</description>
    <pubDate>Mon, 28 Sep 2020 14:12:31 GMT</pubDate>
    <dc:creator>Lina_K</dc:creator>
    <dc:date>2020-09-28T14:12:31Z</dc:date>
    <item>
      <title>Calculate month and quarter based on year and week</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687204#M24509</link>
      <description>&lt;P&gt;I have a column with year (2018-2019) and a column with week number (01-52). Do you know how to create two columns with information on month and quarter based on information about year and week?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example data:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;YEAR&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;WEEK&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;MONTH&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;QUARTER&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2018&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1(Jan)&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1st&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2018&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1(Jan)&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1st&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2018&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;51&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;12(Dec)&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4th&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687204#M24509</guid>
      <dc:creator>Lina_K</dc:creator>
      <dc:date>2020-09-28T13:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate month and quarter based on year and week</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687210#M24512</link>
      <description>&lt;P&gt;Try using INTNX() to calculate date.&amp;nbsp; Then you can use MONTH() and QTR() functions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input ID YEAR WEEK wantMONTH $ wantQUARTER $;
  date = intnx('week',mdy(1,1,year),week-1,'s');
  month=month(date);
  quarter=qtr(date);
  format date yymmdd10.;
cards;
1 2018 1 1(Jan) 1st
1 2018 2 1(Jan) 1st
1 2018 51 12(Dec) 4th
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                              want       want
Obs    ID    YEAR    WEEK     MONTH     QUARTER          date    month    quarter

 1      1    2018      1     1(Jan)       1st      2018-01-01       1        1
 2      1    2018      2     1(Jan)       1st      2018-01-08       1        1
 3      1    2018     51     12(Dec)      4th      2018-12-17      12        4
&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687210#M24512</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-28T13:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate month and quarter based on year and week</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687214#M24513</link>
      <description>Thank you Tom! It works perfectly.</description>
      <pubDate>Mon, 28 Sep 2020 14:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculate-month-and-quarter-based-on-year-and-week/m-p/687214#M24513</guid>
      <dc:creator>Lina_K</dc:creator>
      <dc:date>2020-09-28T14:12:31Z</dc:date>
    </item>
  </channel>
</rss>

