<?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: Categorizing based on multiple observations per person in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631025#M77734</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (PersonID    Color ) ($);*   Color_Category;
cards;

31515         Green   Multicolor

31515         Blue      Multicolor

31515         Green   Multicolor

31515         Blue      Multicolor

64790         Green   Green

64790         Green   Green

64790         Green   Green

64790         Green   Green

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue
;
proc sql;
create table want as
select *,ifc(count(distinct color)&amp;gt;1,'Multicolor',color) as Color_Category
from have
group by personid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 10 Mar 2020 17:21:34 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-03-10T17:21:34Z</dc:date>
    <item>
      <title>Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631024#M77733</link>
      <description>&lt;P&gt;Hello Everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wanting to create a category column based on the values from another column. Please see the table below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PersonID&amp;nbsp; &amp;nbsp; Mode_of_Instruction&amp;nbsp; &amp;nbsp; Instruction_Category&lt;/P&gt;&lt;P&gt;31515&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100 % Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Mixed&lt;/P&gt;&lt;P&gt;31515&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;In Person&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mixed&lt;/P&gt;&lt;P&gt;31515&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50% Online&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mixed&lt;/P&gt;&lt;P&gt;31515&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50% Online&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Mixed&lt;/P&gt;&lt;P&gt;64790&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;In Person&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;In Person&lt;/P&gt;&lt;P&gt;64790&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;In Person&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;In Person&lt;/P&gt;&lt;P&gt;64790&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;75% Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; In Person&lt;/P&gt;&lt;P&gt;64790&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50% Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; In Person&lt;/P&gt;&lt;P&gt;83409&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100% Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100% Online&lt;/P&gt;&lt;P&gt;83409&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100% Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100% Online&lt;/P&gt;&lt;P&gt;83409&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100% Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100% Online&lt;/P&gt;&lt;P&gt;83409&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100% Online&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100% Online&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The column called "Instruction_Category" is what I would like to create. Notice a few things:&lt;/P&gt;&lt;P&gt;- There are multiple observations per person&lt;/P&gt;&lt;P&gt;- If a person has more than one mode_of_instruction, and it includes "100% Online", then the instruction_category is "Mixed"&lt;/P&gt;&lt;P&gt;- If a person has more than one mode_of_instruction, and it does &lt;STRONG&gt;not&lt;/STRONG&gt; include "100% Online", then the instruction_category is "In Person"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this makes sense- please let me know if clarifications are needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 14:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631024#M77733</guid>
      <dc:creator>bourdeax</dc:creator>
      <dc:date>2020-03-11T14:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631025#M77734</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (PersonID    Color ) ($);*   Color_Category;
cards;

31515         Green   Multicolor

31515         Blue      Multicolor

31515         Green   Multicolor

31515         Blue      Multicolor

64790         Green   Green

64790         Green   Green

64790         Green   Green

64790         Green   Green

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue
;
proc sql;
create table want as
select *,ifc(count(distinct color)&amp;gt;1,'Multicolor',color) as Color_Category
from have
group by personid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 17:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631025#M77734</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-10T17:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631027#M77735</link>
      <description>&lt;P&gt;Great use of IFC!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 17:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631027#M77735</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-10T17:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631028#M77736</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *,case when max(color) ne min(color) then 'MultiColour'
            else colour end as Color_Category
from have
group by personid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Slight variation using max/min - you can use max/min on character functions in SQL.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 17:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631028#M77736</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-10T17:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631030#M77738</link>
      <description>&lt;P&gt;And an overly predictable rather increasingly boring DOW for me lately&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input (PersonID    Color ) ($);*   Color_Category;
cards;

31515         Green   Multicolor

31515         Blue      Multicolor

31515         Green   Multicolor

31515         Blue      Multicolor

64790         Green   Green

64790         Green   Green

64790         Green   Green

64790         Green   Green

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue
;
data want;
  do _n_=0 by 0 until(last.personid);
   set have;
   by personid color notsorted;
   if first.color then _n_=sum(_n_,1);
  end;
  length Color_Category $10;
  Color_Category=ifc(_n_&amp;gt;1,'Multicolor',color);
  do until(last.personid);
   set have;
   by personid;
   output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2020 17:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631030#M77738</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-10T17:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631031#M77739</link>
      <description>Thanks, this is exactly what I needed!</description>
      <pubDate>Tue, 10 Mar 2020 17:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631031#M77739</guid>
      <dc:creator>bourdeax</dc:creator>
      <dc:date>2020-03-10T17:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Categorizing based on multiple observations per person</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631036#M77740</link>
      <description>&lt;P&gt;And this &lt;STRONG&gt;traditional one, recalling&amp;nbsp;&lt;/STRONG&gt;my initial days where I used to read to voraciously read Guru&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;'s posts and ask/beg him for help. And Guru offered this one(easy one) to cheer me and said "you will have your time soon"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (PersonID    Color ) ($);*   Color_Category;
cards;

31515         Green   Multicolor

31515         Blue      Multicolor

31515         Green   Multicolor

31515         Blue      Multicolor

64790         Green   Green

64790         Green   Green

64790         Green   Green

64790         Green   Green

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue

83409         Blue      Blue
;
proc freq data=have noprint;
 tables personid*color/out=temp(keep=personid count);
run;
proc freq data=temp noprint;
 tables personid/out=temp2(keep=personid count);
run;

data want;
 merge have temp2;
 by personid;
 length Color_Category $10;
 Color_Category=ifc(count&amp;gt;1,'Multicolor',color);
 drop count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Guru DN, dedicating to all your help as always and every time I mention is a way of showing my heartfelt gratitude. Turn on your sense of humor, you must have gone a lot more grey now. lol &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 17:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Categorizing-based-on-multiple-observations-per-person/m-p/631036#M77740</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-10T17:44:45Z</dc:date>
    </item>
  </channel>
</rss>

