<?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: IF THEN statement from multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537264#M147721</link>
    <description>&lt;P&gt;If you only have one variable, "and" is logically impossible.&amp;nbsp; This comparison can never be true:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if var="a" and var="b" then new_var=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other (usually more complex) ways to solve the "or" problem.&amp;nbsp; But for any solution to work, you can't escape having to type out all the values once.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Feb 2019 01:47:48 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-02-21T01:47:48Z</dc:date>
    <item>
      <title>IF THEN statement from multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537236#M147708</link>
      <description>&lt;P&gt;Hello,&amp;nbsp; I need to create a variable from a large set of other variables (&amp;gt;100) using an IF THEN statement. I know how to do this the "hard"&amp;nbsp; way in my case by listing each single variable separated by an "or" condition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF var='a' or var='b' or var='c' or var='d' or var='e'...... THEN new_var=1; ELSE new_var=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, considering the large number of variables I am dealing with, I am wondering if there is a more efficient way of creating such a variable (such as just copying/pasting all the variables and using on only one "var=, or" condition) rather than listing every single variable after "var=" and followed by my "or" condition. Please note that the 'var' variable is a character variable and again, there are &amp;gt;100 different values of "var' that I need to include. I also need the condition to be an "or" condition, not "and."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help with this would be much appreciated. Thank you very much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 22:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537236#M147708</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-02-20T22:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN statement from multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537238#M147710</link>
      <description>&lt;P&gt;Your post invites this question.&amp;nbsp; Do you really have 100 variables, or do you have one variable that might take on 100 different values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's the latter, here's an abbreviation for checking them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if var in ('a', 'b', 'c', 'd', 'e') then new_var=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other ways, but let's first clarify the real problem here.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 22:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537238#M147710</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-20T22:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN statement from multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537257#M147719</link>
      <description>&lt;P&gt;Yes, I apologize for misspeaking. I need to include many different values of one variable (e.g., var), not 100 different variables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your code and it worked. Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Out of curiosity, what are other ways of creating this variable given this situation? What if I needed to have an "and" condition instead of "or"?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 23:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537257#M147719</guid>
      <dc:creator>wj2</dc:creator>
      <dc:date>2019-02-20T23:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN statement from multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537264#M147721</link>
      <description>&lt;P&gt;If you only have one variable, "and" is logically impossible.&amp;nbsp; This comparison can never be true:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if var="a" and var="b" then new_var=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other (usually more complex) ways to solve the "or" problem.&amp;nbsp; But for any solution to work, you can't escape having to type out all the values once.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 01:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-statement-from-multiple-variables/m-p/537264#M147721</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-21T01:47:48Z</dc:date>
    </item>
  </channel>
</rss>

