<?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 How do I add a column to a dataset that stores categories from three other columns? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516178#M3094</link>
    <description>&lt;P&gt;&lt;SPAN&gt;New SAS user here!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my dataset I am comparing three different diets (A,B, and C) in how they affect weight loss. Currently, my data has a column for the weightloss, followed by three columns A, B, and C. If A=1 it means the person was on diet A (columns B and C would have 0, the diets are mutually exclusive). I don't want three columns with 1s and 0s like this though. I just want one simple column called "Diet" That stores either A, B, or C. How do I do this?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Nov 2018 23:11:50 GMT</pubDate>
    <dc:creator>DoctorShemp</dc:creator>
    <dc:date>2018-11-26T23:11:50Z</dc:date>
    <item>
      <title>How do I add a column to a dataset that stores categories from three other columns?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516178#M3094</link>
      <description>&lt;P&gt;&lt;SPAN&gt;New SAS user here!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my dataset I am comparing three different diets (A,B, and C) in how they affect weight loss. Currently, my data has a column for the weightloss, followed by three columns A, B, and C. If A=1 it means the person was on diet A (columns B and C would have 0, the diets are mutually exclusive). I don't want three columns with 1s and 0s like this though. I just want one simple column called "Diet" That stores either A, B, or C. How do I do this?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 23:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516178#M3094</guid>
      <dc:creator>DoctorShemp</dc:creator>
      <dc:date>2018-11-26T23:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a column to a dataset that stores categories from three other columns?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516179#M3095</link>
      <description>You can code them as A, B, C or 1, 2, 3. &lt;BR /&gt;&lt;BR /&gt;name = whichn(1, A, B, C);&lt;BR /&gt;&lt;BR /&gt;I think this would code it as 1, 2, 3. If that works for you.</description>
      <pubDate>Mon, 26 Nov 2018 23:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516179#M3095</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-26T23:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a column to a dataset that stores categories from three other columns?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516181#M3096</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input  a b c ;
cards;
1 0 0
0 1 0
0 0 1
0 1 0
run;

data want;
set have;
array nm a b c;
diet=' ';
do i =1 to dim(nm) while(diet eq ' ') ;
	if nm[i] &amp;gt; 0 then diet=vname(nm[i]);
end;

drop a b c i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 23:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516181#M3096</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-11-26T23:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a column to a dataset that stores categories from three other columns?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516183#M3097</link>
      <description>&lt;P&gt;Use the transformation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;diet = char("ABCX", whichn(1, A, B, C, 1));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 23:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516183#M3097</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-26T23:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add a column to a dataset that stores categories from three other columns?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516184#M3098</link>
      <description>&lt;P&gt;Thank you! this is the simplest solution that did exactly what I was trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you to everyone else who responded as well, this community is crazy helpful&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 23:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-add-a-column-to-a-dataset-that-stores-categories-from/m-p/516184#M3098</guid>
      <dc:creator>DoctorShemp</dc:creator>
      <dc:date>2018-11-26T23:44:52Z</dc:date>
    </item>
  </channel>
</rss>

