<?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: Issues creating a dummy variable with if, then, or statements in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446078#M4984</link>
    <description>&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
    <pubDate>Fri, 16 Mar 2018 05:18:58 GMT</pubDate>
    <dc:creator>dman</dc:creator>
    <dc:date>2018-03-16T05:18:58Z</dc:date>
    <item>
      <title>Issues creating a dummy variable with if, then, or statements</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446074#M4982</link>
      <description>&lt;P&gt;here is my SAS code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data nypd.aaa(compress=yes);&lt;BR /&gt;set nypd.master_y;&lt;/P&gt;&lt;P&gt;x_bw=0; if ARSTOFFN="CRIMINAL MISCHIEF" or "MAKING GRAFFITI" then x_bw=1;&lt;/P&gt;&lt;P&gt;label x_bw="Stops that led to arrest for Criminal Mischief or Making Graffiti";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a dummy variable that combines existing character variables in the dataset, which would be a metric for Broken Windows crimes. After testing the newly created x_bw variable with proc freq, it seems that the variable has only counted "CRIMINAL MISCHIEF". When I look look at the code, the "or" statement is not in blue text and seems that it is not performing its function. How can I get the "or" statement to work so that I can combine the variables into a dummy variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 04:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446074#M4982</guid>
      <dc:creator>dman</dc:creator>
      <dc:date>2018-03-16T04:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issues creating a dummy variable with if, then, or statements</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446076#M4983</link>
      <description>&lt;P&gt;OR is not a statement. It is a boolean operator that takes two operands.&amp;nbsp; If either operand is TRUE then the result is TRUE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But &lt;SPAN&gt;"MAKING GRAFFITI" is not a expression that has true/false value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You probably meant this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ARSTOFFN="CRIMINAL MISCHIEF" or ARSTOFFN="MAKING GRAFFITI" then x_bw=1
else x_bw=0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Or since SAS will generate 1 for True and 0 for False you could eliminate the IF THEN ELSE part and just do this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x_bw=ARSTOFFN="CRIMINAL MISCHIEF" or ARSTOFFN="MAKING GRAFFITI" ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;You could also look into using the IN operator instead.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x_bw=ARSTOFFN in ("CRIMINAL MISCHIEF" "MAKING GRAFFITI" ) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 05:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446076#M4983</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-16T05:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issues creating a dummy variable with if, then, or statements</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446078#M4984</link>
      <description>&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 05:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Issues-creating-a-dummy-variable-with-if-then-or-statements/m-p/446078#M4984</guid>
      <dc:creator>dman</dc:creator>
      <dc:date>2018-03-16T05:18:58Z</dc:date>
    </item>
  </channel>
</rss>

