<?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 Requirement on SAS code in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576570#M13073</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attaching the snap here&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="New Query.PNG" style="width: 408px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31303iAFEF293CF539708E/image-dimensions/408x402?v=v2" width="408" height="402" role="button" title="New Query.PNG" alt="New Query.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in above column, Seriesvar has&amp;nbsp;3 variable , F1,F2,F3 . So for each seriesVar, first we need to check that if in&amp;nbsp;the first row of each variable , quantity is 0 then we need to select 4 rows below that and if first row of series var is not 0 then select 4 rows from starting of that seriesvar. I have highlighted the rows which I want as output. Month is also sorted in descending order so we can put logic in this way also like if Max month of a seriesVar have quantity 0 , then skip that row and select next 4 rows of that seriesvar. it should be by series Var.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to write code for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2019 12:55:15 GMT</pubDate>
    <dc:creator>priyanka14</dc:creator>
    <dc:date>2019-07-25T12:55:15Z</dc:date>
    <item>
      <title>Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576570#M13073</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attaching the snap here&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="New Query.PNG" style="width: 408px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31303iAFEF293CF539708E/image-dimensions/408x402?v=v2" width="408" height="402" role="button" title="New Query.PNG" alt="New Query.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in above column, Seriesvar has&amp;nbsp;3 variable , F1,F2,F3 . So for each seriesVar, first we need to check that if in&amp;nbsp;the first row of each variable , quantity is 0 then we need to select 4 rows below that and if first row of series var is not 0 then select 4 rows from starting of that seriesvar. I have highlighted the rows which I want as output. Month is also sorted in descending order so we can put logic in this way also like if Max month of a seriesVar have quantity 0 , then skip that row and select next 4 rows of that seriesvar. it should be by series Var.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to write code for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 12:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576570#M13073</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-25T12:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576571#M13074</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279386"&gt;@priyanka14&lt;/a&gt;&amp;nbsp; &amp;nbsp;Please post the sample as plain text or in the datastep format so that community members can copy paste easily rather than pics.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 12:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576571#M13074</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-25T12:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576574#M13076</link>
      <description>&lt;P&gt;Would you also be kind enough to rename your original post so there is a meaningful title, such as "Selecting Certain Rows"?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 13:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576574#M13076</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-25T13:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576576#M13077</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id quantity;
cards;
1 0
1 3
1 4
1 3
1 5
1 6
2 4
2 3
2 0
2 3
2 6
2 6
;

data temp;
 set have;
 by id;
 retain found 0;
 if first.id then found=0;
 if quantity ne 0 then found=1;
run;
data temp;
 set temp;
 by id found;
 if first.found then n=0;
 n+1;
run;
data want;
 set temp;
 if found and n in (1:4);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 13:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576576#M13077</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-25T13:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576579#M13078</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id quantity;
cards;
1 0
1 3
1 4
1 3
1 5
1 6
2 4
2 3
2 0
2 3
2 6
2 6
;




data want;
do _n_=0 by 1 until(last.id);
set have;
by id;
if _n_=0 and quantity ne 0 then _n_=1;
if _n_ in (1:4) then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 13:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576579#M13078</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-25T13:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576617#M13082</link>
      <description>&lt;P&gt;Is there &lt;STRONG&gt;ever&lt;/STRONG&gt; an occurrence where one of the SeriesVar groups will &lt;STRONG&gt;not&lt;/STRONG&gt; have 4 records? This is potentially important as if you select 4 records when the SeriesVar group has fewer than 4 records then you will 1) select records from a different group and 2) proabaly miss the proper start for the next group (since the records were selected for the previous group).&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 14:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576617#M13082</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-25T14:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576890#M13119</link>
      <description>Thank you so much. This code is working absolutely fine. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 26 Jul 2019 13:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576890#M13119</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-26T13:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Requirement on SAS code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576892#M13121</link>
      <description>Thank you so much. Both the code is working as per requirement .. Really Appreciate the efforts. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 26 Jul 2019 13:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Requirement-on-SAS-code/m-p/576892#M13121</guid>
      <dc:creator>priyanka14</dc:creator>
      <dc:date>2019-07-26T13:13:29Z</dc:date>
    </item>
  </channel>
</rss>

