<?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 Create a variable with case when in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454745#M69999</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a dataset where the Race Category was input rather oddly.&lt;/P&gt;&lt;P&gt;Essentially, I have 8 binary variables, Race_White, Race_Black, Race_Asian, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each variable the response is 0 if false or 1 if true.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to combine each of these variables into a single race category for analysis.&lt;/P&gt;&lt;P&gt;Essentially creating a variable of Race where 1=White, 2=Black, 3=Asian etc. from the binary variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I am striking out. it seems to me this should be an if then function but I seem to be missing something&lt;/P&gt;</description>
    <pubDate>Tue, 17 Apr 2018 14:03:14 GMT</pubDate>
    <dc:creator>DanielQuay</dc:creator>
    <dc:date>2018-04-17T14:03:14Z</dc:date>
    <item>
      <title>Create a variable with case when</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454745#M69999</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with a dataset where the Race Category was input rather oddly.&lt;/P&gt;&lt;P&gt;Essentially, I have 8 binary variables, Race_White, Race_Black, Race_Asian, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each variable the response is 0 if false or 1 if true.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to combine each of these variables into a single race category for analysis.&lt;/P&gt;&lt;P&gt;Essentially creating a variable of Race where 1=White, 2=Black, 3=Asian etc. from the binary variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I am striking out. it seems to me this should be an if then function but I seem to be missing something&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 14:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454745#M69999</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2018-04-17T14:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable with case when</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454748#M70000</link>
      <description>&lt;P&gt;Will the variables only be populated once?&amp;nbsp; If so you could just do:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  select (sum(of race_:));
    when 1 then race="White";
    when 2 then race=...;
    ...
  end;
run;&lt;/PRE&gt;
&lt;P&gt;If not then you would need to do each one, and cat the result:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array r{*} race_;;
  do i=1 to dim(r);
    if r{i}=1 then race=catx(',',race,vname(r{i});
  end;
  race=tranwrd(race,"race_","");
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Apr 2018 14:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454748#M70000</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-17T14:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable with case when</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454775#M70001</link>
      <description>&lt;P&gt;It's not odd. It's done this way to account for multiple entries, ie someone can flag both White and Black, and &lt;STRONG&gt;it's also how a regression model requires the variables for analysis -&lt;/STRONG&gt; with the dummy coded values of 0/1.&amp;nbsp; Make sure you need to change it first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with a dataset where the Race Category was input rather oddly.&lt;/P&gt;
&lt;P&gt;Essentially, I have 8 binary variables, Race_White, Race_Black, Race_Asian, etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each variable the response is 0 if false or 1 if true.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to combine each of these variables into a single race category for analysis.&lt;/P&gt;
&lt;P&gt;Essentially creating a variable of Race where 1=White, 2=Black, 3=Asian etc. from the binary variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far I am striking out. it seems to me this should be an if then function but I seem to be missing something&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 14:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454775#M70001</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-17T14:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable with case when</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454863#M70002</link>
      <description>&lt;P&gt;Thanks for the assistance, though I figured out how to do it without using an array.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I was having was a simple thing in my data statement.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 17:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-a-variable-with-case-when/m-p/454863#M70002</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2018-04-17T17:25:17Z</dc:date>
    </item>
  </channel>
</rss>

