<?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 Transforming a categorical variable into a binary variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776547#M31388</link>
    <description>&lt;P&gt;Hello, I have a large dataset that contains multiple categorical variables.&lt;/P&gt;&lt;P&gt;For each variable, entry options are:&lt;/P&gt;&lt;P&gt;Yes / No / Unknown / Missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to transform each variable into a binary variable: Yes vs. No/Unknown/Missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two questions:&lt;/P&gt;&lt;P&gt;1) Is there a way to do this directly in proc freq or is it necessary to create a large number of new variables (e.g. apple_bin, orange_bin) in a data step first?&lt;/P&gt;&lt;P&gt;2)&amp;nbsp; If a data step is necessary, is there a way to generate all of these new variables using a do loop?&amp;nbsp;Each variable has a different name (e.g., apples, oranges, bananas) so I can't use a range (var1-var3).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much,&lt;/P&gt;&lt;P&gt;Emily&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 16:55:16 GMT</pubDate>
    <dc:creator>EmilyAV</dc:creator>
    <dc:date>2021-10-26T16:55:16Z</dc:date>
    <item>
      <title>Transforming a categorical variable into a binary variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776547#M31388</link>
      <description>&lt;P&gt;Hello, I have a large dataset that contains multiple categorical variables.&lt;/P&gt;&lt;P&gt;For each variable, entry options are:&lt;/P&gt;&lt;P&gt;Yes / No / Unknown / Missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to transform each variable into a binary variable: Yes vs. No/Unknown/Missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two questions:&lt;/P&gt;&lt;P&gt;1) Is there a way to do this directly in proc freq or is it necessary to create a large number of new variables (e.g. apple_bin, orange_bin) in a data step first?&lt;/P&gt;&lt;P&gt;2)&amp;nbsp; If a data step is necessary, is there a way to generate all of these new variables using a do loop?&amp;nbsp;Each variable has a different name (e.g., apples, oranges, bananas) so I can't use a range (var1-var3).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much,&lt;/P&gt;&lt;P&gt;Emily&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 16:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776547#M31388</guid>
      <dc:creator>EmilyAV</dc:creator>
      <dc:date>2021-10-26T16:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming a categorical variable into a binary variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776548#M31389</link>
      <description>One method illustrated here and then several links at the bottom with other options:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-dummy-variables-Categorical-Variables/ta-p/308484" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-dummy-variables-Categorical-Variables/ta-p/308484&lt;/A&gt;</description>
      <pubDate>Tue, 26 Oct 2021 17:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776548#M31389</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-26T17:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming a categorical variable into a binary variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776549#M31390</link>
      <description>FYI - most procs in SAS don't require this if they support the CLASS statement which will do it as part of the PROC. If you're using PROC LOGISTIC, PHREG for example it will do this automatically, no need to recode them yourself manually.</description>
      <pubDate>Tue, 26 Oct 2021 17:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776549#M31390</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-26T17:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming a categorical variable into a binary variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776551#M31391</link>
      <description>&lt;P&gt;Should&amp;nbsp;&lt;SPAN&gt;No/Unknown/Missing all transform to 0 ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 17:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776551#M31391</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-10-26T17:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming a categorical variable into a binary variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776559#M31392</link>
      <description>&lt;P&gt;It depends on your ultimate objective.&amp;nbsp; If you just want to run PROC FREQ, that can be done easily:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $yes  'Yes' = '1'    'No', 'Missing', 'Unknown' = '0';
run;

proc freq data=have;
   tables _character_;
   format _character_ $yes.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Oct 2021 17:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transforming-a-categorical-variable-into-a-binary-variable/m-p/776559#M31392</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-10-26T17:53:33Z</dc:date>
    </item>
  </channel>
</rss>

