<?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: Creating new binomial variable from multiple binomial variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789771#M252771</link>
    <description>&lt;P&gt;Sum the binary variables, and test to see if this sum is greater than or equal to 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if sum(football,tennis,rugby,swimming)&amp;gt;=2 then multi_sport_athlete=1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Jan 2022 18:00:40 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-12T18:00:40Z</dc:date>
    <item>
      <title>Creating new binary variable from multiple binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789769#M252770</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a new binary variable (yes =1, no = 0) based on if ≥2 of a set of other binary variables are =1 per individual in the cohort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In other words, I could name my new variable "multi_sport_athlete" and would set it as 1 only if this same individual played 2 or more of any sports, with variables such as "tennis" = 1, "football" = 1 , "rugby" = 1, "swimming" =1 .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 18:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789769#M252770</guid>
      <dc:creator>tofov2</dc:creator>
      <dc:date>2022-01-12T18:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new binomial variable from multiple binomial variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789771#M252771</link>
      <description>&lt;P&gt;Sum the binary variables, and test to see if this sum is greater than or equal to 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if sum(football,tennis,rugby,swimming)&amp;gt;=2 then multi_sport_athlete=1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jan 2022 18:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789771#M252771</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-12T18:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new binomial variable from multiple binomial variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789773#M252772</link>
      <description>&lt;P&gt;If you have numeric 0/1 coded variables then you can use the SUM function to get the number of values equal to 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the layout of your data is needed to recommend exact code. Provide an example of the needed variables in the form of a data step and what the expected result for the example data might be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have variables (which are very seldom in quotes in SAS code) named Tennis, Football,Rugby and swimming then a data step such as:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   Multi_sport_athlete= ( sum(tennis,football, rugby, swimming) ge 2);
run;&lt;/PRE&gt;
&lt;P&gt;should work. SAS will return 1 for true and 0 for false in a comparisons such as Somevar = ( &amp;lt;comparison code goes here&amp;gt;);&lt;/P&gt;
&lt;P&gt;Note that if all the sport variable values are missing this will assign 0. So if you don't want that behavior you need to be a bit more descriptive about rules.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 18:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-new-binary-variable-from-multiple-binary-variables/m-p/789773#M252772</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-12T18:01:19Z</dc:date>
    </item>
  </channel>
</rss>

