<?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 with character multiple condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807281#M33615</link>
    <description>&lt;P&gt;Are you sure that the variable "HbsAg" has the values "Reactive" and/or "Non-Reactive"? Maybe a format changing the way the value is shown. I would expect the variable to have values like 0 and 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
    <pubDate>Tue, 12 Apr 2022 06:01:56 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-04-12T06:01:56Z</dc:date>
    <item>
      <title>If/Then statement with character multiple condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807265#M33612</link>
      <description>&lt;P&gt;hiyya,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do an if statement with multiple clauses but i keep on getting an error or my new variable only follows the last else statement. please help I know they are all not unknown&lt;/P&gt;&lt;P&gt;here is the code:&lt;/P&gt;&lt;PRE&gt;data new.step;&lt;BR /&gt;set new.HepBV;&lt;BR /&gt;	length result $40.;	&lt;BR /&gt;	if HbsAg = 'Non-Reactive' and Anti_HBs_surface = 'Reactive' and Anti_Hbc_Total = 'Non-Reactive'&lt;BR /&gt;		then result = "Immune due to Vaccination";&lt;BR /&gt;	&lt;BR /&gt;	else if HbsAg = 'Non-Reactive' and Anti_HBs_surface = 'Reactive' and Anti_Hbc_Total = 'Reactive'&lt;BR /&gt;		then result = "Immune due to Resolved Infection";&lt;BR /&gt;		&lt;BR /&gt;	else if HbsAg = 'Reactive' and Anti_HBs_surface = 'Ron-Reactive' and Anti_Hbc_Total = 'Reactive' and IgM_anti_HBc = 'Reactive'&lt;BR /&gt;		then result = "Acute infection";	&lt;BR /&gt;		&lt;BR /&gt;	else if HbsAg = "Reactive" and Anti_HBs_surface = "Non-Reactive" and Anti_Hbc_Total = "Reactive" and IgM_anti_HBc = "Non-Reactive"&lt;BR /&gt;		then result = "Chronic infection";&lt;BR /&gt;	&lt;BR /&gt;	else if HbsAg = 'Non-Reactive' and Anti_HBs_surface = 'Non-Reactive' and Anti_Hbc_Total = 'Reactive'&lt;BR /&gt;		then result = "several possible interpretation";&lt;BR /&gt;	&lt;BR /&gt;	else if hebimm= "Y" then result = "Immune due to Vaccination";&lt;BR /&gt;	&lt;BR /&gt;	else result = "Unknown";&lt;BR /&gt;	RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 00:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807265#M33612</guid>
      <dc:creator>Cooksam13</dc:creator>
      <dc:date>2022-04-12T00:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then statement with character multiple condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807266#M33613</link>
      <description>&lt;P&gt;Sounds like none of the values you are looking for are in the data.&lt;/P&gt;
&lt;P&gt;Check what values are actually in the data.&lt;/P&gt;
&lt;P&gt;Use the $QUOTE format so that you can see if there are any leading spaces in the values (ODS outputs tend to remove leading spaces from the values they display).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=new.HepBV order=freq ;
  tables HbsAg*Anti_HBs_surface*Anti_Hbc_Total / list missing;
  format HbsAg Anti_HBs_surface Anti_Hbc_Total $quote.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 00:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807266#M33613</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-12T00:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then statement with character multiple condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807280#M33614</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;Any time&lt;/STRONG&gt; &lt;/U&gt;&lt;/EM&gt;you get an error, copy the entire procedure or data set code along with all notes, warning and errors from the LOG and then on the forum open a text box using the &amp;lt;/&amp;gt; icon and paste the text.&lt;/P&gt;
&lt;P&gt;The text box will preserve formatting of any diagnostic characters that SAS includes with many errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you did not provide a Length for the variable Result and if Result did not exist in the data set this code sets the length of the value to 24 because the first use is assigning the value "Immune due to Vaccination", which means any string longer than that is truncated. If Result already existed in the data set then the characteristics of the existing variable may mean values are truncated even more, or if Result was numeric would result in a bunch of messages about trying to convert character values to numeric and failing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check your data to see if those first combinations appear in the data with the spelling you used by using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc freq data=new.hepbv;
   tables HbsAg*Anti_HBS_surface*Anit_hbc_total / list missing;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 05:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807280#M33614</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-12T05:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: If/Then statement with character multiple condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807281#M33615</link>
      <description>&lt;P&gt;Are you sure that the variable "HbsAg" has the values "Reactive" and/or "Non-Reactive"? Maybe a format changing the way the value is shown. I would expect the variable to have values like 0 and 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 06:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-statement-with-character-multiple-condition/m-p/807281#M33615</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-04-12T06:01:56Z</dc:date>
    </item>
  </channel>
</rss>

