<?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: Recode multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573179#M161780</link>
    <description>&lt;P&gt;As long as you know the values are 0/1 then just take the max.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_var=max(of var1-var8);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jul 2019 18:24:56 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-12T18:24:56Z</dc:date>
    <item>
      <title>Recode multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573178#M161779</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to recode a set of 8 variables into a single variable, such that if all 8 are missing then the new variable is missing, but if even one of the variable = '1' then the new variable = '1'; else the new variable = '0'. I know how to that in long hand (see below), but was wondering is there was a better way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data two; set one;&lt;/P&gt;&lt;P&gt;if var1 = . and var2 = . and var3 = . and var4 = . and var5 = . and var6 = . and var7 = . and var8 = . then new_var = .;&lt;/P&gt;&lt;P&gt;else if var1 = 1 or var2 = 1 or var3 =&amp;nbsp;1 or var4 = 1 or var5 = 1 or var6 = 1 or var7 = 1 or var8 = 1 then new_var = 1;&lt;/P&gt;&lt;P&gt;else new_var = 0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 18:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573178#M161779</guid>
      <dc:creator>aowais</dc:creator>
      <dc:date>2019-07-12T18:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Recode multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573179#M161780</link>
      <description>&lt;P&gt;As long as you know the values are 0/1 then just take the max.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_var=max(of var1-var8);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 18:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573179#M161780</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-12T18:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Recode multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573181#M161781</link>
      <description>&lt;P&gt;Thanks! It works!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 18:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recode-multiple-variables/m-p/573181#M161781</guid>
      <dc:creator>aowais</dc:creator>
      <dc:date>2019-07-12T18:30:34Z</dc:date>
    </item>
  </channel>
</rss>

