<?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: create a quarter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495535#M130792</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to&amp;nbsp;create a quarter variable based on a date variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FORMAT of the date is YYMMDDD10. (e.g.,1990-09-29). I use the code like&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Step1.Appln_newQuarter;
   SET Step1.appln_new;
   IF MONTH(earliest_filing_date)=1 or 2 or 3 THEN quarter=1;
   ELSE IF MONTH(earliest_filing_date)=4 or 5 or 6 THEN quarter=2;
   ELSE IF MONTH(earliest_filing_date)=7 or 8 or 9 THEN quarter=3;
   ELSE IF MONTH(earliest_filing_date)=10 or 11 or 12 THEN quarter=4;   
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but the result is '1'. could you please give me some suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For a very large number of purposes you may not even need to create an additional variable at all. SAS provides several formats for date values that will display quarters: QTRw. by default displays 1 to 4, QTRRw. which displays quarter as Roman numerals: I II III and IV, YYQw which will show year and quarter information together depending on width YYQ. default shows YYYYQn such as 2018Q1 or YYQxw. where you choose a charcter for x that controls the separator between the year and quarter numbe allowing such things as 2012/3 or 2017-2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Analysis procedures will honor the formatted value for grouping purposes.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 21:42:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-09-13T21:42:08Z</dc:date>
    <item>
      <title>create a quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495493#M130779</link>
      <description>&lt;P&gt;dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to&amp;nbsp;create a quarter variable based on a date variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The FORMAT of the date is YYMMDDD10. (e.g.,1990-09-29). I use the code like&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Step1.Appln_newQuarter;
   SET Step1.appln_new;
   IF MONTH(earliest_filing_date)=1 or 2 or 3 THEN quarter=1;
   ELSE IF MONTH(earliest_filing_date)=4 or 5 or 6 THEN quarter=2;
   ELSE IF MONTH(earliest_filing_date)=7 or 8 or 9 THEN quarter=3;
   ELSE IF MONTH(earliest_filing_date)=10 or 11 or 12 THEN quarter=4;   
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but the result is '1'. could you please give me some suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 20:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495493#M130779</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-13T20:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: create a quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495501#M130781</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;DATA&lt;/SPAN&gt; Step1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Appln_newQuarter&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;SET&lt;/SPAN&gt; Step1&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;appln_new&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;quarter=qtr&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;earliest_filing_date&lt;SPAN class="token punctuation"&gt;);&lt;/SPAN&gt;
     
&lt;SPAN class="token procnames"&gt;RUN&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use the qtr function&amp;nbsp; -- is all you need i think&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 20:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495501#M130781</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-13T20:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: create a quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495535#M130792</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194466"&gt;@France&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to&amp;nbsp;create a quarter variable based on a date variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The FORMAT of the date is YYMMDDD10. (e.g.,1990-09-29). I use the code like&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Step1.Appln_newQuarter;
   SET Step1.appln_new;
   IF MONTH(earliest_filing_date)=1 or 2 or 3 THEN quarter=1;
   ELSE IF MONTH(earliest_filing_date)=4 or 5 or 6 THEN quarter=2;
   ELSE IF MONTH(earliest_filing_date)=7 or 8 or 9 THEN quarter=3;
   ELSE IF MONTH(earliest_filing_date)=10 or 11 or 12 THEN quarter=4;   
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but the result is '1'. could you please give me some suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For a very large number of purposes you may not even need to create an additional variable at all. SAS provides several formats for date values that will display quarters: QTRw. by default displays 1 to 4, QTRRw. which displays quarter as Roman numerals: I II III and IV, YYQw which will show year and quarter information together depending on width YYQ. default shows YYYYQn such as 2018Q1 or YYQxw. where you choose a charcter for x that controls the separator between the year and quarter numbe allowing such things as 2012/3 or 2017-2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Analysis procedures will honor the formatted value for grouping purposes.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 21:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-quarter/m-p/495535#M130792</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-13T21:42:08Z</dc:date>
    </item>
  </channel>
</rss>

