<?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: will &amp;quot;do until&amp;quot; work  here? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625130#M77402</link>
    <description>&lt;P&gt;this works&lt;/P&gt;
&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
    <pubDate>Sun, 16 Feb 2020 20:05:59 GMT</pubDate>
    <dc:creator>Tal</dc:creator>
    <dc:date>2020-02-16T20:05:59Z</dc:date>
    <item>
      <title>will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625125#M77400</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hello SAS experts&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is just a&amp;nbsp; piece of my code and&amp;nbsp; sum_opp which is the sum of opp per account is always&amp;gt;4 but i need to cap i to 4 meaning for the&amp;nbsp; first account&amp;nbsp; &amp;nbsp;i need to overwrite one "1" for opp&amp;nbsp; from any of the 5 records to "0"&lt;/P&gt;
&lt;P&gt;or for the second account i need to overwrite opp=1 to opp=0 in any two records and so on....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I m&amp;nbsp; trying&amp;nbsp; this code below but not working, not even sure it is correct .Can anyone pls assist me?&amp;nbsp; Thx&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data temp;&lt;BR /&gt;input accnt name sale opp sum_opp;&lt;BR /&gt;cards;&lt;BR /&gt;100 miki 1 1 5 &lt;BR /&gt;100 maya 1 1 5&lt;BR /&gt;100 mono 0 1 5&lt;BR /&gt;100 vera 1 1 5&lt;BR /&gt;100 bono 0 1 5&lt;BR /&gt;101 riki 1 1 6 &lt;BR /&gt;101 zara 1 1 6&lt;BR /&gt;101 rono 0 1 6&lt;BR /&gt;101 vera 1 1 6&lt;BR /&gt;101 xue 0 1 6&lt;BR /&gt;101 xu 0 1 6&lt;BR /&gt;;&lt;BR /&gt;proc sort data=temp;by accnt; run;&lt;/P&gt;
&lt;P&gt;data temp2;&lt;BR /&gt;set temp;&lt;BR /&gt;by accnt;&lt;BR /&gt;count=1;&lt;BR /&gt;do until(count&amp;gt;sum_opp-4);&lt;BR /&gt;if opp=1 then do; opp=0; count=count+1;end;&lt;BR /&gt;else do; opp=opp;count=count; end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 18:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625125#M77400</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-02-16T18:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625129#M77401</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34400"&gt;@Tal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say « &lt;I&gt;I need to overwrite one "1" for opp&amp;nbsp; from any of the 5 records to "0"&lt;/I&gt; », how do you choose&amp;nbsp;the records to modify? As data are not sorted by name inside accounts, does it matter to choose the last records by default ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if not, does this code make sense?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp2;
   set temp;
   by accnt;
   if first.accnt then count=0;
   if opp=1 then count+1;
   if count &amp;gt; 4 then opp=0;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Feb 2020 19:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625129#M77401</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-16T19:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625130#M77402</link>
      <description>&lt;P&gt;this works&lt;/P&gt;
&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 20:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625130#M77402</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-02-16T20:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625137#M77403</link>
      <description>&lt;P&gt;Awesome! You’re welcome&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34400"&gt;@Tal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 20:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/625137#M77403</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-16T20:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/626188#M77443</link>
      <description>&lt;P&gt;hello ed_sas_member,&lt;/P&gt;
&lt;P&gt;and&amp;nbsp; what if I did not&amp;nbsp; have to overwrite opp randomly, what if&amp;nbsp; lets&amp;nbsp; say&amp;nbsp; the oldest holders within an account should be set to "0"&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;&amp;nbsp; I have the&amp;nbsp; age in my data and&amp;nbsp; lets&amp;nbsp; say&amp;nbsp; zara and&amp;nbsp; riki&amp;nbsp; from&amp;nbsp; the account 101&amp;nbsp; are the oldest&amp;nbsp; and&amp;nbsp; I want them set to 0?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thx&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 16:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/626188#M77443</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-02-20T16:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/626257#M77444</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34400"&gt;@Tal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an approach to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
input accnt name $ age sale opp sum_opp;
cards;
100 miki 30 1 1 5 
100 maya 25 1 1 5
100 mono 65 0 1 5
100 vera 56 1 1 5
100 bono 28 0 1 5
101 riki 80 1 1 6 
101 zara 79 1 1 6
101 rono 60 0 1 6
101 vera 30 1 1 6
101 xue 40 0 1 6
101 xu 60 0 1 6
;

data temp_id;
	set temp;
	id+1; /*set a unique id for each row*/
run;

proc sort data=temp_id;
	by accnt age;
run;

data temp2;
   set temp_id;
   by accnt age;
   if first.accnt then count=0;
   if opp=1 then count+1;
   if count &amp;gt; 4 then opp=0;
run;

proc sort data=temp2;
	by id; /*sort data to have them in the initial order*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 18:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/626257#M77444</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-20T18:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: will "do until" work  here?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/626306#M77445</link>
      <description>&lt;P&gt;ahh I was&amp;nbsp; trying&amp;nbsp; "by accnt||age" and that's&amp;nbsp; why was not working for me. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 19:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/will-quot-do-until-quot-work-here/m-p/626306#M77445</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2020-02-20T19:28:53Z</dc:date>
    </item>
  </channel>
</rss>

