<?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 How to use '%' in if ... then statements in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525230#M4912</link>
    <description>&lt;P&gt;Probably an easy task for a pro but I got stuck with this trivial problem for quite some time now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have this table as a start:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data inTable;&lt;BR /&gt;input ICD $ Drugs MDD&amp;nbsp;;&lt;BR /&gt;datalines;&lt;BR /&gt;F111 . .&lt;BR /&gt;F60 . .&lt;BR /&gt;F132 . .&lt;BR /&gt;F323 . .&lt;BR /&gt;F331 . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;I want to get the following results table:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data outtableDesired;&lt;BR /&gt;input ICD $ Drugs MDD&amp;nbsp;;&lt;BR /&gt;datalines;&lt;BR /&gt;F111 1.&lt;BR /&gt;F60 . .&lt;BR /&gt;F132 1 .&lt;BR /&gt;F323 . 1&lt;BR /&gt;F331 . 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I tried the following:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data outtable;&lt;BR /&gt;set inTable;&lt;BR /&gt;if ICD in ('F11%','F13%') then do;&lt;BR /&gt;Drugs=1;&lt;BR /&gt;end;&lt;BR /&gt;if ICD in ('F32%','F33%') then do;&lt;BR /&gt;MDD=1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently '%' does not work in 'if ... then' procedures ... or? Any alternatives? Of course, my real table is much larger with many more options for ICD, that's why I have to write just the beginning of the character string and then '%'.&lt;/P&gt;&lt;P&gt;Thanks in advance for your time to help me with a solution!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jan 2019 21:28:12 GMT</pubDate>
    <dc:creator>haukewiegand</dc:creator>
    <dc:date>2019-01-07T21:28:12Z</dc:date>
    <item>
      <title>How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525230#M4912</link>
      <description>&lt;P&gt;Probably an easy task for a pro but I got stuck with this trivial problem for quite some time now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have this table as a start:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data inTable;&lt;BR /&gt;input ICD $ Drugs MDD&amp;nbsp;;&lt;BR /&gt;datalines;&lt;BR /&gt;F111 . .&lt;BR /&gt;F60 . .&lt;BR /&gt;F132 . .&lt;BR /&gt;F323 . .&lt;BR /&gt;F331 . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;I want to get the following results table:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data outtableDesired;&lt;BR /&gt;input ICD $ Drugs MDD&amp;nbsp;;&lt;BR /&gt;datalines;&lt;BR /&gt;F111 1.&lt;BR /&gt;F60 . .&lt;BR /&gt;F132 1 .&lt;BR /&gt;F323 . 1&lt;BR /&gt;F331 . 1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I tried the following:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data outtable;&lt;BR /&gt;set inTable;&lt;BR /&gt;if ICD in ('F11%','F13%') then do;&lt;BR /&gt;Drugs=1;&lt;BR /&gt;end;&lt;BR /&gt;if ICD in ('F32%','F33%') then do;&lt;BR /&gt;MDD=1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently '%' does not work in 'if ... then' procedures ... or? Any alternatives? Of course, my real table is much larger with many more options for ICD, that's why I have to write just the beginning of the character string and then '%'.&lt;/P&gt;&lt;P&gt;Thanks in advance for your time to help me with a solution!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525230#M4912</guid>
      <dc:creator>haukewiegand</dc:creator>
      <dc:date>2019-01-07T21:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525234#M4915</link>
      <description>&lt;P&gt;Shouldn't the syntax be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data outtable;
set inTable;
if ICD like ('F11%') or ICD like ('F13%') then do;
Drugs=1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525234#M4915</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-07T21:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525239#M4917</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; Are you trying to use the % as a wildcard? The % and the _ work with the LIKE operator in a WHERE statement or clause. You cannot use them in an IF statement. &lt;BR /&gt; But, if you are searching for F11 or F13 in the beginning of a string (so your full value is something like F11AB or F1134 or F13BC, then using the =: logical operator can work in an IF statement.&lt;BR /&gt;&lt;BR /&gt;See this example.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IF_not_LIKE.png" style="width: 562px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26077i10DE2C62FDE794DF/image-size/large?v=v2&amp;amp;px=999" role="button" title="IF_not_LIKE.png" alt="IF_not_LIKE.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525239#M4917</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-01-07T21:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525248#M4922</link>
      <description>&lt;P&gt;Thanks, that's working well!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hauke&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525248#M4922</guid>
      <dc:creator>haukewiegand</dc:creator>
      <dc:date>2019-01-07T21:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525251#M4923</link>
      <description>&lt;P&gt;Note that the : modifier works with the IN operator also.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if code in: ('F11' 'F13') then .... ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 22:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525251#M4923</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-07T22:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525306#M4933</link>
      <description>Hi, Tom:&lt;BR /&gt;  Good point!&lt;BR /&gt;Cynthia</description>
      <pubDate>Tue, 08 Jan 2019 01:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525306#M4933</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-01-08T01:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use '%' in if ... then statements</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525590#M4992</link>
      <description>&lt;P&gt;Thanks, that really&amp;nbsp;makes it easier!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hauke&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 21:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-in-if-then-statements/m-p/525590#M4992</guid>
      <dc:creator>haukewiegand</dc:creator>
      <dc:date>2019-01-08T21:50:41Z</dc:date>
    </item>
  </channel>
</rss>

