<?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: Multiple If/Then/Else statements with wildcard in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668542#M200424</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if HOSPSTCO=:'23' or '33' or '50' or '25' or '44' or '09' then HOSP_DIVISION=1; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This must generate quite a few note sin the log about type conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These notes should never be tolerated: They indicate that the compiler finds data inconsistencies in the way a program is written&lt;/P&gt;
&lt;P&gt;Remove the notes and the new program will work as expected.&lt;/P&gt;
&lt;P&gt;Hint: &amp;nbsp; &amp;nbsp; &lt;CODE class=" language-sas"&gt;HOSPSTCO=:'23'&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is a Boolean number&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;'&lt;/CODE&gt;&lt;/STRONG&gt;&lt;CODE class=" language-sas"&gt;33&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;'&lt;/CODE&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; is also a Boolean number&lt;/P&gt;</description>
    <pubDate>Sat, 11 Jul 2020 11:32:37 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-07-11T11:32:37Z</dc:date>
    <item>
      <title>Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668484#M200387</link>
      <description>&lt;P&gt;I'm trying to create a new column by grouping variables from a different column to a new output. I'm also trying to identify those variables just by their first 2 digits using a wildcard. When I run the following, the output just puts "1" in the new column for all rows, even if doesn't abide by the intended "if" statement. I'm not quite sure why it does that and fails to have the intended output in the new column.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test; 
	set test; 
	if HOSPSTCO=:'23' or '33' or '50' or '25' or '44' or '09' then HOSP_DIVISION=1; 
	else if HOSPSTCO=:'36' or '42' or '34' then HOSP_DIVISION=2; 
	else if HOSPSTCO=:'55' or '26' or '17' or '18' or '39' then HOSP_DIVISION=3; 
	else if HOSPSTCO=:'29' or '38' or '46' or '31' or '20' or '27' or '19' then HOSP_DIVISION=4; 
	else if HOSPSTCO=:'10' or '24' or '11' or '51' or '54' or '37' or '45' or '13' or '12' then HOSP_DIVISION=5; 
	else if HOSPSTCO=:'21' or '47' or '28' or '01' then HOSP_DIVISION=6; 
	else if HOSPSTCO=:'40' or '48' or '05' or '22' then HOSP_DIVISION=7; 
	else if HOSPSTCO=:'16' or '30' or '56' or '32' or '49' or '08' or '04' or '35' then HOSP_DIVISION=8; 
	else if HOSPSTCO=:'02' or '53' or '41' or '06' or '15' then HOSP_DIVISION=9; 
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Jul 2020 21:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668484#M200387</guid>
      <dc:creator>lturian</dc:creator>
      <dc:date>2020-07-10T21:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668485#M200388</link>
      <description>&lt;P&gt;The proper syntax is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if HOSPSTCO=:'23' or HOSPSTCO=:'33' or HOSPSTCO=:'50' or 
    HOSPSTCO=:'25' or HOSPSTCO=:'44' or HOSPSTCO=:'09' 
    then HOSP_DIVISION=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Alternative&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if substr(hospstco,1,2) in ('23','33','50','25','44','09') then hosp_division=1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2020 21:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668485#M200388</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T21:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668487#M200390</link>
      <description>&lt;P&gt;The proper operator to use is IN .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; if substr(HOSPSTCO,1,2) in ('23' '33' '50' '25' '44' '09') then HOSP_DIVISION=1; &lt;/LI-CODE&gt;
&lt;P&gt;Or use the SELECT When for doing lots of comparisons instead of If/then/else&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test2; 
	set test; 
   select (substr(HOSPSTCO,1,2));
   	When ('23' , '33' , '50' , '25' , '44' , '09' ) HOSP_DIVISION=1; 
   	When ('36' , '42' , '34' ) HOSP_DIVISION=2; 
   	When ('55' , '26' , '17' , '18' , '39' ) HOSP_DIVISION=3; 
   	When ('29' , '38' , '46' , '31' , '20' , '27' , '19' ) HOSP_DIVISION=4; 
   	When ('10' , '24' , '11' , '51' , '54' , '37' , '45' , '13' , '12' ) HOSP_DIVISION=5; 
   	When ('21' , '47' , '28' , '01' ) HOSP_DIVISION=6; 
   	When ('40' , '48' , '05' , '22' ) HOSP_DIVISION=7; 
   	When ('16' , '30' , '56' , '32' , '49' , '08' , '04' , '35' ) HOSP_DIVISION=8; 
   	When ('02' , '53' , '41' , '06' , '15' ) HOSP_DIVISION=9; 
      otherwise;
   end;
run; &lt;/PRE&gt;
&lt;P&gt;The otherwise is not required but there will be a warning if not present. It is to do what ever you might want if none of the values appear in the other When conditions. Such as perhaps put a warning to the log about an unexpected value or missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another alternative if you have a data set with the code values and categories would be to create a format to assign the division code and just use the format instead of adding another variable.&lt;/P&gt;
&lt;P&gt;This takes advantage of an oddity in range comparisons of character values:&lt;/P&gt;
&lt;PRE&gt;proc format;
value $hospdiv
'23' - '2399'= 'Division 1'
'33' - '3399'= 'Division 1'
'36' - '3699'= 'Division 2'
'42' - '4299'= 'Division 2'
;
run;

data junk;
  input x $;
  put x= $hospdiv.;
datalines;
23
231
2345
33
3356
36
367
3678
42
4244
;&lt;/PRE&gt;
&lt;P&gt;I have several formats that are used to turn location codes into regions, nested region/subregion (multilabel formats), long and short descriptions.&lt;/P&gt;
&lt;P&gt;Groups created with formats will be honored by most analysis, reporting and graphing procedures. They have a big advantage that if you need to make a small "tweek" you only need to modify Format code and do not have to go back to the data set to add yet another variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 21:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668487#M200390</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-10T21:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668488#M200391</link>
      <description>&lt;P&gt;Formats are your friend.&lt;/P&gt;
&lt;P&gt;Untested but something like this is a lot cleaner and easier to maintain and test. My nickel at least.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue  hosp_division
'23'  '33'  '50' '25'  '44' '09'  = 1
'36'  '42'  '34' = 2
'55'  '26'  '17'  '18'  '39' =3;
run;

data test2;*use a different name otherwise it's hard to track changes over time and harder to debug;
set test; 

hosp_division = input(substr(hospstco, 1, 2), hosp_division.);
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/326745"&gt;@lturian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to create a new column by grouping variables from a different column to a new output. I'm also trying to identify those variables just by their first 2 digits using a wildcard. When I run the following, the output just puts "1" in the new column for all rows, even if doesn't abide by the intended "if" statement. I'm not quite sure why it does that and fails to have the intended output in the new column.&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test; 
	set test; 
	if HOSPSTCO=:'23' or '33' or '50' or '25' or '44' or '09' then HOSP_DIVISION=1; 
	else if HOSPSTCO=:'36' or '42' or '34' then HOSP_DIVISION=2; 
	else if HOSPSTCO=:'55' or '26' or '17' or '18' or '39' then HOSP_DIVISION=3; 
	else if HOSPSTCO=:'29' or '38' or '46' or '31' or '20' or '27' or '19' then HOSP_DIVISION=4; 
	else if HOSPSTCO=:'10' or '24' or '11' or '51' or '54' or '37' or '45' or '13' or '12' then HOSP_DIVISION=5; 
	else if HOSPSTCO=:'21' or '47' or '28' or '01' then HOSP_DIVISION=6; 
	else if HOSPSTCO=:'40' or '48' or '05' or '22' then HOSP_DIVISION=7; 
	else if HOSPSTCO=:'16' or '30' or '56' or '32' or '49' or '08' or '04' or '35' then HOSP_DIVISION=8; 
	else if HOSPSTCO=:'02' or '53' or '41' or '06' or '15' then HOSP_DIVISION=9; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 21:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668488#M200391</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-10T21:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668490#M200393</link>
      <description>&lt;P&gt;All good replies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if in the real-world example there are cases where you sometimes want the first two characters of HOSPSTCO and other cases where you want the first three (or four or ... ) characters to match, then I think all of the solutions fail except the IF/THEN construct. But maybe I'm wrong, maybe there's a way to get the SUBSTR or FORMAT solution to work there, I just can think of it right now.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 22:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668490#M200393</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-10T22:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668492#M200395</link>
      <description>I think this code is the hospital modified FIPS State/County code, which is why this solution should work overall. But it definitely may not generalize to all IF/THEN questions.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.hcup-us.ahrq.gov/db/vars/hospstco/kidnote.jsp" target="_blank"&gt;https://www.hcup-us.ahrq.gov/db/vars/hospstco/kidnote.jsp&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Jul 2020 22:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668492#M200395</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-10T22:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668505#M200403</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just curious whether you tried to replace this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hosp_division = input(substr(hospstco, 1, 2), hosp_division.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is it possible this would work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hosp_division = input(hospstco, hosp_division2.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Jul 2020 02:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668505#M200403</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-07-11T02:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668512#M200405</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just curious whether you tried to replace this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hosp_division = input(substr(hospstco, 1, 2), hosp_division.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is it possible this would work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hosp_division = input(hospstco, hosp_division2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That will work.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 03:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668512#M200405</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-11T03:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668513#M200406</link>
      <description>&lt;P&gt;What do you think the result should be to your boolean expressions that are comparing two strings with the OR operator?&amp;nbsp; Let's test it and see what SAS does.&lt;/P&gt;
&lt;PRE&gt;567   data _null_;
568     if '01' or '02' then put 'yes';
569     else put 'no';
570   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      568:6    568:14
yes
&lt;/PRE&gt;
&lt;P&gt;So it looks like it will convert those strings to numbers and do the OR.&amp;nbsp; SAS will treat any value other than zero or missing as TRUE so your first IF test is going to always be true since all of the strings look like non-zero numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to compare one variable to any of a series of value using the IN operator. You can use the colon modifier on the IN operator just like you used it on the equals operator.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if HOSPSTCO in: ('23'  '33'  '50'  '25'  '44'  '09') then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 03:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668513#M200406</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-11T03:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668514#M200407</link>
      <description>When I try this, it doesn't output any variable into HOSP_DIVISION. Every row just has "." instead of the desired output. I wonder if the problem lies with the HOSPSTCO data</description>
      <pubDate>Sat, 11 Jul 2020 04:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668514#M200407</guid>
      <dc:creator>lturian</dc:creator>
      <dc:date>2020-07-11T04:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668516#M200408</link>
      <description>I tried both ways and for some reason I'm not getting anything in the new column. I'm just getting "." in all rows.</description>
      <pubDate>Sat, 11 Jul 2020 04:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668516#M200408</guid>
      <dc:creator>lturian</dc:creator>
      <dc:date>2020-07-11T04:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668518#M200409</link>
      <description>I do like formats. But for some reason I'm not getting anything the formatted variables in the new column. I'm just getting "." in all rows.</description>
      <pubDate>Sat, 11 Jul 2020 04:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668518#M200409</guid>
      <dc:creator>lturian</dc:creator>
      <dc:date>2020-07-11T04:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668534#M200417</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/326745"&gt;@lturian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I do like formats. But for some reason I'm not getting anything the formatted variables in the new column. I'm just getting "." in all rows.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;42&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Values? Format / informat definition? Code used?&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 10:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668534#M200417</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-11T10:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668537#M200419</link>
      <description>&lt;P&gt;Why is this condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if HOSPSTCO=:'23' or '33' or '50' or '25' or '44' or '09' then HOSP_DIVISION=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;always true?&lt;/P&gt;
&lt;P&gt;Well, in a condition, the comparisons take precedence, then the NOT operator, then AND, then OR.&lt;/P&gt;
&lt;P&gt;Therefore your condition translates to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (HOSPSTCO=:'23') or ('33') or ('50') or ('25') or ('44') or ('09') then HOSP_DIVISION=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since a boolean value needs to be numeric, the character values are converted on-the-fly, and since they all convert to non-zero and non-missing numbers, they are considered true, so this condition as a whole will always be true.&lt;/P&gt;
&lt;P&gt;You want to use the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lepg&amp;amp;docsetTarget=p1n8bsqqd03xppn17pgvjpjlbhhs.htm&amp;amp;locale=en#n1qev6umhhr2xbn1ky0c8bc8sna7" target="_blank" rel="noopener"&gt;IN&lt;/A&gt; operator and a set of values.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 10:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668537#M200419</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-11T10:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668538#M200420</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/326745"&gt;@lturian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;When I try this, it doesn't output any variable into HOSP_DIVISION. Every row just has "." instead of the desired output. I wonder if the problem lies with the HOSPSTCO data&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then LOOK AT the data in data set TEST with your own eyes.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 11:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668538#M200420</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-11T11:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668542#M200424</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if HOSPSTCO=:'23' or '33' or '50' or '25' or '44' or '09' then HOSP_DIVISION=1; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This must generate quite a few note sin the log about type conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These notes should never be tolerated: They indicate that the compiler finds data inconsistencies in the way a program is written&lt;/P&gt;
&lt;P&gt;Remove the notes and the new program will work as expected.&lt;/P&gt;
&lt;P&gt;Hint: &amp;nbsp; &amp;nbsp; &lt;CODE class=" language-sas"&gt;HOSPSTCO=:'23'&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is a Boolean number&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;'&lt;/CODE&gt;&lt;/STRONG&gt;&lt;CODE class=" language-sas"&gt;33&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;STRONG&gt;&lt;CODE class=" language-sas"&gt;'&lt;/CODE&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; is also a Boolean number&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 11:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668542#M200424</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-07-11T11:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668572#M200442</link>
      <description>&lt;P&gt;I used the invalue format you provided:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	invalue FIPS
	'23' '33' '50' '25' '44' '09' = 1
	'36' '42' '34' = 2
	'55' '26' '17' '18' '39' = 3
	'29' '38' '46' '31' '20' '27' '19' = 4
	'10' '24' '11' '51' '54' '37' '45' '13' '12' = 5
	'21' '47' '28' '01' = 6
	'40' '48' '05' '22' = 7
	'16' '30' '56' '32' '49' '08' '04' '35' = 8
	'02' '53' '41' '06' '15' = 9
	;
run;

data test2;
	set test;
HOSP_DIVISION = input(substr(HOSPSTCO,1,2), FIPS.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Jul 2020 15:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668572#M200442</guid>
      <dc:creator>lturian</dc:creator>
      <dc:date>2020-07-11T15:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668614#M200449</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/326745"&gt;@lturian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I used the invalue format you provided:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	invalue FIPS
	'23' '33' '50' '25' '44' '09' = 1
	'36' '42' '34' = 2
	'55' '26' '17' '18' '39' = 3
	'29' '38' '46' '31' '20' '27' '19' = 4
	'10' '24' '11' '51' '54' '37' '45' '13' '12' = 5
	'21' '47' '28' '01' = 6
	'40' '48' '05' '22' = 7
	'16' '30' '56' '32' '49' '08' '04' '35' = 8
	'02' '53' '41' '06' '15' = 9
	;
run;

data test2;
	set test;
HOSP_DIVISION = input(substr(HOSPSTCO,1,2), FIPS.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And the result was good? bad? ugly? What?&lt;/P&gt;
&lt;P&gt;Are you sure the variable HOSPSTCO is defined as character?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jul 2020 22:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668614#M200449</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-11T22:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple If/Then/Else statements with wildcard</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668719#M200499</link>
      <description>&lt;P&gt;This seems to work for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input HOSPSTCO $ ;
cards;
23000
33000
02124
34002
55343
;
run;


proc format;
	invalue $  FIPS
	'23', '33', '50', '25', '44', '09'                    = 1
	'36', '42', '34'                                      = 2
	'55', '26', '17', '18', '39'                          = 3
	'29', '38', '46', '31', '20', '27', '19'              = 4
	'10', '24', '11', '51', '54', '37', '45', '13', '12'  = 5
	'21', '47', '28', '01'                                = 6
	'40', '48', '05', '22'                                = 7
	'16', '30', '56', '32', '49', '08', '04', '35'        = 8
	'02', '53', '41', '06', '15'                          = 9
	;
run;

data test2;
	set test;
    HOSP_DIVISION = input(substr(HOSPSTCO, 1, 2) , $FIPS.);
    HOSP_DIVISION2 = input(HOSPSTCO, $FIPS2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Jul 2020 23:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-If-Then-Else-statements-with-wildcard/m-p/668719#M200499</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-12T23:58:17Z</dc:date>
    </item>
  </channel>
</rss>

