<?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 a new variable based on the value of multiple other variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550586#M152882</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array f field:;

total_field=ifn(3 in f or (1 in f and 2 in f),3, field1);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Apr 2019 11:54:25 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2019-04-12T11:54:25Z</dc:date>
    <item>
      <title>Creating a new variable based on the value of multiple other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550577#M152877</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have data that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID Field_1 Field_2 Field_3 Field_4 Field_5&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1&lt;/STRONG&gt; 3 1 . . .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2&lt;/STRONG&gt; 1 2 1 . .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3&lt;/STRONG&gt; 1 1 . . .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;4&lt;/STRONG&gt; 2 3 2 . .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5&lt;/STRONG&gt; 2 . . . .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;6&lt;/STRONG&gt; 1 1 1 3 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;ect&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a new variable (Total_Field) based on the values in Fields 1- 5 as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If any Field is 3 then Total_Field = 3&lt;/P&gt;&lt;P&gt;if an id has both a Field = 1 &amp;amp; a Field = 2 then Total_Field = 3&lt;/P&gt;&lt;P&gt;if an id has only Field's= 1 then Total_Field = 1&lt;/P&gt;&lt;P&gt;if an id has only Field's = 2 then Total_Field = 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for the above data Total_Field would be:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID Total_Field&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1&lt;/STRONG&gt; 3&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2&lt;/STRONG&gt; 3&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3&lt;/STRONG&gt; 1&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;4&lt;/STRONG&gt; 3&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5&lt;/STRONG&gt; 2&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;6&lt;/STRONG&gt; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know i could do this with if then statements but it would be really long winded so I'm hoping there is a quicker way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Cydney&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 11:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550577#M152877</guid>
      <dc:creator>CydneyLB</dc:creator>
      <dc:date>2019-04-12T11:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable based on the value of multiple other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550586#M152882</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array f field:;

total_field=ifn(3 in f or (1 in f and 2 in f),3, field1);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 11:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550586#M152882</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-04-12T11:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new variable based on the value of multiple other variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550621#M152891</link>
      <description>&lt;P&gt;This worked perfectly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 13:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-variable-based-on-the-value-of-multiple-other/m-p/550621#M152891</guid>
      <dc:creator>CydneyLB</dc:creator>
      <dc:date>2019-04-12T13:30:09Z</dc:date>
    </item>
  </channel>
</rss>

