<?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: condensing a string in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758848#M30220</link>
    <description>thank you for your help! so is there a way to condense this string at all? or should I just leave it as is?</description>
    <pubDate>Mon, 02 Aug 2021 17:39:13 GMT</pubDate>
    <dc:creator>Cooksam13</dc:creator>
    <dc:date>2021-08-02T17:39:13Z</dc:date>
    <item>
      <title>condensing a string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758844#M30217</link>
      <description>&lt;P&gt;I originally had my data look like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;if index(upcase(tests), 'HEP') then Hepcheck = 1;
else if index(upcase(tests), 'HBSAG') then HEpCheck = 1;
else if index(upcase(remarks), 'HEP') then Hepcheck = 1;
else if index(upcase(remarks), 'HBSAG') then HepCheck = 1;
else Hepcheck = 0;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to condense the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data program.ds2054;&lt;BR /&gt;set sheet.ds2054;&lt;BR /&gt;if index(upcase(tests), 'HEP C' or 'HEPATITIS C') then hepcheck = 0;&lt;BR /&gt;else if index(upcase(tests), 'HEP' or 'HBSAG' or 'HBV') then Hepcheck = 1 ;&lt;BR /&gt;Else if index(upcase(remarks), 'HEP C' or 'HEPATITIS C') then hepcheck =0;&lt;BR /&gt;Else if index(upcase(remarks), 'HEP' or 'HBSAG' or 'HBV') then hepcheck =1;&lt;BR /&gt;&lt;BR /&gt;else Hepcheck = 0;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However I get this error now and no data shows up even though i had a lot of data the other way&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;71:38 71:49 72:43 72:52 72:63 73:32 73:43 74:32 74:41 74:52 75:44 75:55 76:44 76:53 76:64&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;80:39 80:53 81:32 81:46 82:42 82:56&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;71:46 72:60 73:40 74:49 75:23 75:52 76:23 76:61 80:50 81:43 82:22 82:53&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Variable OtherClassBDetails is uninitialized.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid numeric data, 'HEP C' , at line 71 column 38.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid numeric data, 'HEPATITIS C' , at line 71 column 49.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid numeric data, 'HEP' , at line 72 column 43.&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Aug 2021 17:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758844#M30217</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2021-08-02T17:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: condensing a string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758846#M30219</link>
      <description>&lt;P&gt;The result of the boolean expression OR is a numeric value, not a character string. False results are coded as 0 and true as 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So while this tests if HEP C is in the TESTs&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(upcase(tests), 'HEP C' ) then hepcheck = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(upcase(tests), 'HEP C' or 'HEPATITIS C') then hepcheck = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is testing if 0 with 11 leading spaces is in tests.&lt;/P&gt;
&lt;P&gt;Just test each word independently.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data program.ds2054;
set sheet.ds2054;
if index(upcase(tests), 'HEP C' ) then hepcheck = 0;
else if index(upcase(tests), 'HEPATITIS C') then hepcheck = 0;
etc.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Aug 2021 17:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758846#M30219</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-02T17:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: condensing a string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758848#M30220</link>
      <description>thank you for your help! so is there a way to condense this string at all? or should I just leave it as is?</description>
      <pubDate>Mon, 02 Aug 2021 17:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758848#M30220</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2021-08-02T17:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: condensing a string</title>
      <link>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758852#M30222</link>
      <description>&lt;P&gt;Depends on what you are actually doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to test the whole values of the variable TESTS?&amp;nbsp; If so then you could use the IN operation instead of the INDEX() function.&amp;nbsp; Then you could list multiple values to test for in a single expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if upcase(tests) in ('HEP C' 'HEPATITIS C') then ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Aug 2021 17:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/condensing-a-string/m-p/758852#M30222</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-02T17:44:17Z</dc:date>
    </item>
  </channel>
</rss>

