<?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 Create logic for control of quarters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493307#M129761</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some trouble understanding how to set up some logic based on a list I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logic from the list, shown below, should be that it should be sequential, i.e 2016Q1-Q4, but if let's say, 2016Q1 and 2016Q3&amp;nbsp;is missing it should give an output that they are missing.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x;
cards;
2016Q2
2016Q4
2017Q1
2017Q2
2017Q3
2017Q4
2018Q1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The next step I am trying to figure out is that if I want to produce the next report (2018Q2) it should check that [CurrentYear][Q-1] and [CurrentYear-1][Q4] exists, if not it should give an output on what is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 08:34:43 GMT</pubDate>
    <dc:creator>Freppa</dc:creator>
    <dc:date>2018-09-07T08:34:43Z</dc:date>
    <item>
      <title>Create logic for control of quarters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493307#M129761</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some trouble understanding how to set up some logic based on a list I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logic from the list, shown below, should be that it should be sequential, i.e 2016Q1-Q4, but if let's say, 2016Q1 and 2016Q3&amp;nbsp;is missing it should give an output that they are missing.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x;
cards;
2016Q2
2016Q4
2017Q1
2017Q2
2017Q3
2017Q4
2018Q1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The next step I am trying to figure out is that if I want to produce the next report (2018Q2) it should check that [CurrentYear][Q-1] and [CurrentYear-1][Q4] exists, if not it should give an output on what is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Fredrik&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493307#M129761</guid>
      <dc:creator>Freppa</dc:creator>
      <dc:date>2018-09-07T08:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create logic for control of quarters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493311#M129764</link>
      <description>&lt;P&gt;First, set your data to be the correct format:&lt;/P&gt;
&lt;PRE&gt;input quarter yyq9.;&lt;/PRE&gt;
&lt;P&gt;From:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000204480.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000204480.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data test;
  informat x yyq9.;
  format x yyq9.;
  input x;
cards;
2016Q2
2016Q4
2017Q1
2017Q2
2017Q3
2017Q4
2018Q1
;
run;

data want;
  set test;
  if intck('qtr',lag(x),x) ne 1 then output;
run;&lt;/PRE&gt;
&lt;P&gt;Not sure what exactly you want as output, so just guessed.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493311#M129764</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-07T08:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create logic for control of quarters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493533#M129834</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216930"&gt;@Freppa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some trouble understanding how to set up some logic based on a list I have.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic from the list, shown below, should be that it should be sequential, i.e 2016Q1-Q4, but if let's say, 2016Q1 and 2016Q3&amp;nbsp;is missing it should give an output that they are missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x;
cards;
2016Q2
2016Q4
2017Q1
2017Q2
2017Q3
2017Q4
2018Q1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next step I am trying to figure out is that if I want to produce the next report (2018Q2) it should check that [CurrentYear][Q-1] and [CurrentYear-1][Q4] exists, if not it should give an output on what is missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Fredrik&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It really helps to show exactly what you are expecting for output.&lt;/P&gt;
&lt;P&gt;So I am guessing&amp;nbsp; perhaps you want a message in the log about missing?&lt;/P&gt;
&lt;PRE&gt;data test;
  informat x yyq9.;
  format x yyq9.;
  input x;
  retain lastx;
  format lastx yyq9.;
  if intck('quarter',lastx,x)&amp;gt;1 then put "WARNING: Missing quarter between " lastx yyq9. ' and ' x yyq9.;
  lastx=x;
  drop lastx  ;
cards;
2016Q2
2016Q4
2017Q1
2017Q2
2017Q3
2017Q4
2018Q1
;
run;

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you need to provide more information related to "next report". Compare what and where? In another data set?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 16:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-logic-for-control-of-quarters/m-p/493533#M129834</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-07T16:00:08Z</dc:date>
    </item>
  </channel>
</rss>

