<?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 IF/THEN/ELSE Errors in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602456#M8239</link>
    <description>&lt;P&gt;For reference I am using sample code from the certification prep guide. I am using SAS Studio. The scenario is as follows,&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;This scenario uses the Excel file heart.xlsx. Write a SAS program to do the following and store the results in the data set Work.Heart.&lt;/P&gt;&lt;P&gt;• Import the Excel file heart.xlsx.&lt;/P&gt;&lt;P&gt;• Drop the AgeAtDeath and DeathCause variables from the Work.Heart data set.&lt;/P&gt;&lt;P&gt;• Include only the observations where Status=Alive in the Work.Heart data set.&lt;/P&gt;&lt;P&gt;• If the AgeCHDdiag variable has a missing value (.), then do not include the value in Work.Heart.&lt;/P&gt;&lt;P&gt;• Create a new variable Smoking_Status, set its length to 17 characters, and use the following criteria:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is between 0 and less than 6, then Smoking_Status is "None (0–5)".&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is between 6 and 15 inclusively, then Smoking_Status is "Moderate (6–15)".&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is between 16 and 25 inclusively, then Smoking_Status is "Heavy (16–25)".&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is greater than 25, then Smoking_Status is "Very Heavy (&amp;gt;25)".&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If there are any other values for the variable Smoking, set Smoking_Status to "Error".&lt;/P&gt;&lt;P&gt;• Create a two-way frequency table using variables AgeCHDdiag and Smoking_Status and suppress column percentage, row percentage, and cell percentage.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Based on the scenario above, I have created the following code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname practice xlsx '/home/u37611728/PracticeData/heart.xlsx';
 
data work.heart;
	set practice.heart;
	drop ageatdeath deathcause;
	where status='Alive';
	if AgeCHDdiag='.' then delete;
	length Smoking_Status $ 17;
	if &amp;lt;=0 smoking &amp;lt;6 then Smoking_Status='Non-Smoker(0-5)';
		else if 6&amp;lt;= smoking &amp;lt;=15 then Smoking_Status='Moderate (6-15)';
		else if 16&amp;lt;= smoking &amp;lt;=25 then Smoking_Status='Heavy (16-25)';
		else if smoking &amp;gt;25 then Smoking_Status='Very Heavy (&amp;gt;25)';
		else Smoking_Status='Error';
run;

proc freq data=work.heart;
	tables AgeCHDdiag*Smoking_Status / nocol norow nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I checked the answer key in the book and it is the same answer. I am getting the following errors. Any help will be greatly appreciated. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt; 79         if &amp;lt;=0 smoking &amp;lt;6 then Smoking_Status='Non-Smoker(0-5)';
                __
                386
                200
                76
 80         else if 6&amp;lt;= smoking &amp;lt;=15 then Smoking_Status='Moderate (6-15)';
              ____
              160
 ERROR 386-185: Expecting an arithmetic expression.
 
 ERROR 200-322: The symbol is not recognized and will be ignored.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 ERROR 160-185: No matching IF-THEN clause.&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Nov 2019 16:00:41 GMT</pubDate>
    <dc:creator>danalukowski228</dc:creator>
    <dc:date>2019-11-07T16:00:41Z</dc:date>
    <item>
      <title>IF/THEN/ELSE Errors</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602456#M8239</link>
      <description>&lt;P&gt;For reference I am using sample code from the certification prep guide. I am using SAS Studio. The scenario is as follows,&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;This scenario uses the Excel file heart.xlsx. Write a SAS program to do the following and store the results in the data set Work.Heart.&lt;/P&gt;&lt;P&gt;• Import the Excel file heart.xlsx.&lt;/P&gt;&lt;P&gt;• Drop the AgeAtDeath and DeathCause variables from the Work.Heart data set.&lt;/P&gt;&lt;P&gt;• Include only the observations where Status=Alive in the Work.Heart data set.&lt;/P&gt;&lt;P&gt;• If the AgeCHDdiag variable has a missing value (.), then do not include the value in Work.Heart.&lt;/P&gt;&lt;P&gt;• Create a new variable Smoking_Status, set its length to 17 characters, and use the following criteria:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is between 0 and less than 6, then Smoking_Status is "None (0–5)".&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is between 6 and 15 inclusively, then Smoking_Status is "Moderate (6–15)".&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is between 16 and 25 inclusively, then Smoking_Status is "Heavy (16–25)".&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If the value of Smoking is greater than 25, then Smoking_Status is "Very Heavy (&amp;gt;25)".&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;• If there are any other values for the variable Smoking, set Smoking_Status to "Error".&lt;/P&gt;&lt;P&gt;• Create a two-way frequency table using variables AgeCHDdiag and Smoking_Status and suppress column percentage, row percentage, and cell percentage.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Based on the scenario above, I have created the following code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname practice xlsx '/home/u37611728/PracticeData/heart.xlsx';
 
data work.heart;
	set practice.heart;
	drop ageatdeath deathcause;
	where status='Alive';
	if AgeCHDdiag='.' then delete;
	length Smoking_Status $ 17;
	if &amp;lt;=0 smoking &amp;lt;6 then Smoking_Status='Non-Smoker(0-5)';
		else if 6&amp;lt;= smoking &amp;lt;=15 then Smoking_Status='Moderate (6-15)';
		else if 16&amp;lt;= smoking &amp;lt;=25 then Smoking_Status='Heavy (16-25)';
		else if smoking &amp;gt;25 then Smoking_Status='Very Heavy (&amp;gt;25)';
		else Smoking_Status='Error';
run;

proc freq data=work.heart;
	tables AgeCHDdiag*Smoking_Status / nocol norow nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I checked the answer key in the book and it is the same answer. I am getting the following errors. Any help will be greatly appreciated. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt; 79         if &amp;lt;=0 smoking &amp;lt;6 then Smoking_Status='Non-Smoker(0-5)';
                __
                386
                200
                76
 80         else if 6&amp;lt;= smoking &amp;lt;=15 then Smoking_Status='Moderate (6-15)';
              ____
              160
 ERROR 386-185: Expecting an arithmetic expression.
 
 ERROR 200-322: The symbol is not recognized and will be ignored.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 ERROR 160-185: No matching IF-THEN clause.&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602456#M8239</guid>
      <dc:creator>danalukowski228</dc:creator>
      <dc:date>2019-11-07T16:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: IF/THEN/ELSE Errors</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602459#M8240</link>
      <description>&lt;P&gt;Compare very carefully the text between the IF and THEN in lines 79 and 80.&lt;/P&gt;
&lt;P&gt;Hint line 80 has it right.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602459#M8240</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-07T16:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: IF/THEN/ELSE Errors</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602463#M8241</link>
      <description>&lt;P&gt;Thanks for the help. I knew it was something stupid simple that I was overlooking.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2019 16:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-THEN-ELSE-Errors/m-p/602463#M8241</guid>
      <dc:creator>danalukowski228</dc:creator>
      <dc:date>2019-11-07T16:07:27Z</dc:date>
    </item>
  </channel>
</rss>

