<?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 Update group value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update-group-value/m-p/537813#M147975</link>
    <description>Hi Everyone,&lt;BR /&gt;In given dataset we have C1 as party and C2 as group name.&lt;BR /&gt;C1 C2&lt;BR /&gt;1 A&lt;BR /&gt;2 A&lt;BR /&gt;3 A&lt;BR /&gt;4 B&lt;BR /&gt;3 B&lt;BR /&gt;5 B&lt;BR /&gt;1 C&lt;BR /&gt;6 C&lt;BR /&gt;&lt;BR /&gt;Now as we see we have multiple group assigned to different parties for eg party 1 is part of group of A and C as well.&lt;BR /&gt;&lt;BR /&gt;Now let's say we have data as follow:&lt;BR /&gt;&lt;BR /&gt;C1&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;&lt;BR /&gt;We need to assign group names to each one of them but some parties have multiple group names I will assign it the max of group they are part of.&lt;BR /&gt;&lt;BR /&gt;So it would be like this.&lt;BR /&gt;C1 C2&lt;BR /&gt;1 C&lt;BR /&gt;2 A&lt;BR /&gt;3 B&lt;BR /&gt;4 B&lt;BR /&gt;5 B&lt;BR /&gt;6 C&lt;BR /&gt;&lt;BR /&gt;But in case if any group is singular then in that case the group value has to be updated to group value of the other elements of its previous group .&lt;BR /&gt;&lt;BR /&gt;So party 2 was associated with 1 and 3 but now since now 1 has group value as C and 3 has B.&lt;BR /&gt;&lt;BR /&gt;Hence group value must be B or C for pary 2.&lt;BR /&gt;&lt;BR /&gt;So final data would be like this.&lt;BR /&gt;&lt;BR /&gt;C1 C2&lt;BR /&gt;1 C&lt;BR /&gt;2 B or C&lt;BR /&gt;3 B&lt;BR /&gt;4 B&lt;BR /&gt;5 B&lt;BR /&gt;6 C&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 22 Feb 2019 19:01:54 GMT</pubDate>
    <dc:creator>Rohit_1990</dc:creator>
    <dc:date>2019-02-22T19:01:54Z</dc:date>
    <item>
      <title>Update group value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-group-value/m-p/537813#M147975</link>
      <description>Hi Everyone,&lt;BR /&gt;In given dataset we have C1 as party and C2 as group name.&lt;BR /&gt;C1 C2&lt;BR /&gt;1 A&lt;BR /&gt;2 A&lt;BR /&gt;3 A&lt;BR /&gt;4 B&lt;BR /&gt;3 B&lt;BR /&gt;5 B&lt;BR /&gt;1 C&lt;BR /&gt;6 C&lt;BR /&gt;&lt;BR /&gt;Now as we see we have multiple group assigned to different parties for eg party 1 is part of group of A and C as well.&lt;BR /&gt;&lt;BR /&gt;Now let's say we have data as follow:&lt;BR /&gt;&lt;BR /&gt;C1&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;&lt;BR /&gt;We need to assign group names to each one of them but some parties have multiple group names I will assign it the max of group they are part of.&lt;BR /&gt;&lt;BR /&gt;So it would be like this.&lt;BR /&gt;C1 C2&lt;BR /&gt;1 C&lt;BR /&gt;2 A&lt;BR /&gt;3 B&lt;BR /&gt;4 B&lt;BR /&gt;5 B&lt;BR /&gt;6 C&lt;BR /&gt;&lt;BR /&gt;But in case if any group is singular then in that case the group value has to be updated to group value of the other elements of its previous group .&lt;BR /&gt;&lt;BR /&gt;So party 2 was associated with 1 and 3 but now since now 1 has group value as C and 3 has B.&lt;BR /&gt;&lt;BR /&gt;Hence group value must be B or C for pary 2.&lt;BR /&gt;&lt;BR /&gt;So final data would be like this.&lt;BR /&gt;&lt;BR /&gt;C1 C2&lt;BR /&gt;1 C&lt;BR /&gt;2 B or C&lt;BR /&gt;3 B&lt;BR /&gt;4 B&lt;BR /&gt;5 B&lt;BR /&gt;6 C&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Feb 2019 19:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-group-value/m-p/537813#M147975</guid>
      <dc:creator>Rohit_1990</dc:creator>
      <dc:date>2019-02-22T19:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Update group value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update-group-value/m-p/537952#M148042</link>
      <description>&lt;P&gt;If I understood right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
input C1 C2	$;
cards;
1 A
2 A
3 A
4 B
3 B
5 B
1 C
6 C
;
run;
proc sql;
create table temp as
select c1,max(c2) as c2,count(*) as n
 from x
  group by c1
   order by c1;
quit;
data want;
 set temp;
 length lag $ 40;
 retain lag;
 lag=lag(c2);
 if n=1 and _n_ ne 1 then do;
  if lag&amp;gt;c2 then c2=lag;
 end;
 drop n lag;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Feb 2019 11:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update-group-value/m-p/537952#M148042</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-02-23T11:20:42Z</dc:date>
    </item>
  </channel>
</rss>

