<?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: How to categorize the data value in multiple column to create new catergory in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593722#M15564</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID (Race1-Race4)(:$10.);
infile datalines dsd dlm=',';
datalines;
1001,asian,hispanic,white,
1002,,,,
1003,asian,,,
1004,,,Asian,Hispanic
;
data want;
 if _n_=1 then do;
  length key flag $ 40;
  declare hash h();
  h.definekey('key');
  h.definedone();
 end;
 set have;
 h.clear();
 array x{*} $ race:;
 do i=1 to dim(x);
   if not missing(x{i}) then do;key=x{i};h.ref();end;
 end;
 n=h.num_items;
 if n=0 then flag='Missing';
  else if n=1 then flag=coalescec(of x{*});
   else flag='Multiple';
 run;
 proc print;run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 Oct 2019 14:00:45 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-10-03T14:00:45Z</dc:date>
    <item>
      <title>How to categorize the data value in multiple column to create new catergory</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593292#M15501</link>
      <description>&lt;P&gt;I need output for the below yellow last column like this. Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Race1&lt;/TD&gt;&lt;TD&gt;Race2&lt;/TD&gt;&lt;TD&gt;Race3&lt;/TD&gt;&lt;TD&gt;Race4&lt;/TD&gt;&lt;TD&gt;Output&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;TD&gt;asian&lt;/TD&gt;&lt;TD&gt;hispanic&lt;/TD&gt;&lt;TD&gt;white&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Mutiple&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1002&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;"Missing"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1003&lt;/TD&gt;&lt;TD&gt;asian&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;asian&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1004&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Asian&lt;/TD&gt;&lt;TD&gt;Hispani&lt;/TD&gt;&lt;TD&gt;Mutiple&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 02 Oct 2019 10:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593292#M15501</guid>
      <dc:creator>tsureshinvites</dc:creator>
      <dc:date>2019-10-02T10:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize the data value in multiple column to create new catergory</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593302#M15505</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293333"&gt;@tsureshinvites&lt;/a&gt;&amp;nbsp; and welcome to the SAS Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID (Race1-Race4)(:$10.);
infile datalines dsd dlm=',';
datalines;
1001,asian,hispanic,white,
1002,,,,
1003,asian,,,
1004,,,Asian,Hispanic
;

data want(drop=a);
    set have;
    a=cmiss(of Race:);
    if a in (1, 2) then output='Multiple';
    else if a=3    then output=coalescec(of Race:);
    else if a=4    then output='Missing'; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ID    Race1    Race2    Race3    Race4     Output
001   asian    hispanic white              Multiple
1002                                       Missing
1003  asian                                asian
1004           Asian             Hispanic  Multiple&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 11:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593302#M15505</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-02T11:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize the data value in multiple column to create new catergory</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593411#M15514</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array _race(*) race1-race4;
n_values = dim(_race) - cmiss(of _race(*));

if n_values &amp;gt; 1 then output = 'Multiple';
else if n_values = 1 then output = coalescec(of _race(*));
else if n_values = 0 then output = 'Missing';
else output = 'CHECKME';

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does't matter how many race variables you have with this version.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use DIM() to get number of values, CMISS() to find number of missing and then the difference is how many values are filled in.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 15:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593411#M15514</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-02T15:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to categorize the data value in multiple column to create new catergory</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593722#M15564</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID (Race1-Race4)(:$10.);
infile datalines dsd dlm=',';
datalines;
1001,asian,hispanic,white,
1002,,,,
1003,asian,,,
1004,,,Asian,Hispanic
;
data want;
 if _n_=1 then do;
  length key flag $ 40;
  declare hash h();
  h.definekey('key');
  h.definedone();
 end;
 set have;
 h.clear();
 array x{*} $ race:;
 do i=1 to dim(x);
   if not missing(x{i}) then do;key=x{i};h.ref();end;
 end;
 n=h.num_items;
 if n=0 then flag='Missing';
  else if n=1 then flag=coalescec(of x{*});
   else flag='Multiple';
 run;
 proc print;run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 14:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-categorize-the-data-value-in-multiple-column-to-create/m-p/593722#M15564</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-03T14:00:45Z</dc:date>
    </item>
  </channel>
</rss>

