<?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: Loop thru Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-Values/m-p/500516#M133315</link>
    <description>&lt;P&gt;There are some uncertainties in what you have posted so I won't convert your numbers into a data step and write code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, it occurs to me that you have two kinds of records; 1) those with an id and a grp and 2) those with just an id. Within the second group you also have two kinds of records, 3) those with an id that matches a record with that id that has a grp, and 4) those that do not match a record on id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 is done.&lt;/P&gt;
&lt;P&gt;3 is a match merge, find records that match the id in question and give them the group from the matching record.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4 strikes me as something that might could be done with proc surveyselect.&amp;nbsp; It will certainly randomly assign essentially equal groups to all the unassigned ids.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether you would then need to do some additional evening out of group numbers I couldn't say.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Oct 2018 19:26:40 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2018-10-01T19:26:40Z</dc:date>
    <item>
      <title>Loop thru Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-Values/m-p/500159#M133163</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GRP&lt;/P&gt;&lt;P&gt;0001 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0002 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0003 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0004 &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0005 &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0006 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0007 &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0008 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0009 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0010 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0011 &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0012 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0013 &amp;nbsp; &amp;nbsp; &amp;nbsp; D&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0014 &amp;nbsp; &amp;nbsp; &amp;nbsp; B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0015 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0016 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0017 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0018 &amp;nbsp; &amp;nbsp; &amp;nbsp; A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0019 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0020 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0021 &amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0022 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0023 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0024 &amp;nbsp; &amp;nbsp; &amp;nbsp; C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;0001 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0002 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0003 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0004 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0005 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the dataset above - I want to distribute the IDs to GRP (A or B) given the following conditions.&lt;/P&gt;&lt;P&gt;-&amp;nbsp;If the repeated ID value has no assigned GRP then&amp;nbsp;check from other observation if it has GRP value (A or&amp;nbsp;B) and assign the GRP value, if no then assign new GRP.&lt;/P&gt;&lt;P&gt;- Distribute the unassigned IDs to GRP (A or B ) given that the GRP must have equal or at least near number of assigned IDs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this can be done using loop in SAS but I don't know how to distribute the ID values after counting or getting the ID count on each group&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the desired output; the highlighted Yellow GRPs were IDs that were previously assigned and the Blue are the new assigned IDs to GRPs.&lt;/P&gt;&lt;P&gt;The table on the right side explains the distribution of remaining IDs to the GRP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sample.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23656i4C10337533055E4F/image-size/large?v=v2&amp;amp;px=999" role="button" title="sample.png" alt="sample.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 30 Sep 2018 07:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-thru-Values/m-p/500159#M133163</guid>
      <dc:creator>Hypatia</dc:creator>
      <dc:date>2018-09-30T07:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Loop thru Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-Values/m-p/500516#M133315</link>
      <description>&lt;P&gt;There are some uncertainties in what you have posted so I won't convert your numbers into a data step and write code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, it occurs to me that you have two kinds of records; 1) those with an id and a grp and 2) those with just an id. Within the second group you also have two kinds of records, 3) those with an id that matches a record with that id that has a grp, and 4) those that do not match a record on id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 is done.&lt;/P&gt;
&lt;P&gt;3 is a match merge, find records that match the id in question and give them the group from the matching record.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4 strikes me as something that might could be done with proc surveyselect.&amp;nbsp; It will certainly randomly assign essentially equal groups to all the unassigned ids.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether you would then need to do some additional evening out of group numbers I couldn't say.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 19:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-thru-Values/m-p/500516#M133315</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-10-01T19:26:40Z</dc:date>
    </item>
  </channel>
</rss>

