<?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 statement did not work? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/836457#M330725</link>
    <description>&lt;P&gt;I keep getting an error message every time I run the code. I went over it with my TA and assumed everything was correct but I keep getting error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error message I get;&amp;nbsp;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;Please help the assignment is due tomorrow!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* I am trying to answer question 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is in the editor window:&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname hw3 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3';&lt;BR /&gt;data fit1temp;&lt;BR /&gt;set hw3.fit2;if upcase(compress(smoke)) = "CURRENTSMOKER" then currentsmoker = 1;&lt;BR /&gt;else if upcase(compress(smoke)) = "NONSMOKER" or&lt;BR /&gt;upcase(compress(smoke)) = "FORMERSMOKER" then currentsmoker = 0&lt;BR /&gt;proc freq data=hw3.fit2;&lt;BR /&gt;table blvfx blnspfx;&lt;BR /&gt;if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;&lt;BR /&gt;else if blvfx = "no" and blnspfx = "no" then = any_base_frac = 0;&lt;BR /&gt;if newvfx = "yes" and newnspfx = "yes" then any_new_frac = 1;&lt;BR /&gt;else if newvfx = "no" and newnspfx = "no" then any_new_frac = 0;&lt;BR /&gt;if bmi &amp;gt; 25 then bmi2 = "overweight";&lt;BR /&gt;else if 0 &amp;lt; bmi &amp;lt;= 25 then bmi2 = "normal";&lt;BR /&gt;if 0 &amp;lt; bmi &amp;lt;= 18 then bmi3 = "underweight";&lt;BR /&gt;else if 18 &amp;lt; bmi &amp;lt;= 25 then bmi3 = "normal";&lt;BR /&gt;else if bmi &amp;gt; 25 then bmi3 = "overweight";&lt;/P&gt;&lt;P&gt;bmi1_ind = (bmi &amp;gt; 25);&lt;BR /&gt;bmi2_ind = (18 &amp;lt; bmi &amp;lt;= 25);&lt;BR /&gt;bmi3_ind = (0 &amp;lt; bmi &amp;lt;= 18);&lt;BR /&gt;i_tx = (tx = "Alendronate");&lt;BR /&gt;diff_bmd = cobmd-blbmd;&lt;BR /&gt;age = (dov - dob)/365.25;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2022 03:16:23 GMT</pubDate>
    <dc:creator>MisterJenn</dc:creator>
    <dc:date>2022-10-03T03:16:23Z</dc:date>
    <item>
      <title>If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807195#M318184</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to make the change in the code shown below.&amp;nbsp; &amp;nbsp;'&lt;CODE class=" language-sas"&gt;uairway&lt;/CODE&gt;' and '&lt;CODE class=" language-sas"&gt;ulungoth&lt;/CODE&gt;' are numeric; while '&lt;CODE class=" language-sas"&gt;uairwayothsp&lt;/CODE&gt;', '&lt;CODE class=" language-sas"&gt;Ulungothsp&lt;/CODE&gt;', and '&lt;CODE class=" language-sas"&gt;record_updated&lt;/CODE&gt;' are the character.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=ulungoth Ulungothsp record_updated uairway uairwayothsp);
	set have;

	if caseid in ('EUJK009') then Ulungothsp='CHRONIC RESPIRATORY FAILURE, BIPAP DEPENDENT' and ulungoth=1 
									and record_updated='Yes' and uairway=0 and uairwayothsp=' ';

	if caseid in ('EUJK009');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log window showed the massage below:&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;BR /&gt;236:48&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;237:76&lt;BR /&gt;NOTE: Invalid numeric data, 'CHRONIC RESPIRATORY FAILURE, BIPAP DEPENDENT' , at line 236 column 48.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, I didn't see any change in the result I want in the (&lt;CODE class=" language-sas"&gt;ulungoth Ulungothsp record_updated uairway uairwayothsp&lt;/CODE&gt;) columns.&amp;nbsp; &amp;nbsp;Where did I do wrong and how to fix it?&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807195#M318184</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-04-11T16:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807198#M318187</link>
      <description>&lt;P&gt;Please show us the &lt;FONT color="#FF0000"&gt;entire&lt;/FONT&gt; log for this data step, including the code as it appears in the log, as well as all NOTEs, WARNINGs and ERRORs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From now on, please do not show us errors detached from the code that caused the error.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807198#M318187</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-11T16:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807199#M318188</link>
      <description>&lt;P&gt;Unless you want a dataset of identical rows... I guess you may want something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=ulungoth Ulungothsp record_updated uairway uairwayothsp);
	set have;

	if caseid in ('EUJK009') then do;
		Ulungothsp='CHRONIC RESPIRATORY FAILURE, BIPAP DEPENDENT';
		ulungoth=1;
		record_updated='Yes';
		uairway=0;
		uairwayothsp=' ';
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i.e. to execute many statements when a condition is true, you need a DO END group.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807199#M318188</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2022-04-11T16:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807200#M318189</link>
      <description>Awesome, thanks much!</description>
      <pubDate>Mon, 11 Apr 2022 16:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807200#M318189</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-04-11T16:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807202#M318191</link>
      <description>&lt;P&gt;This expression:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'CHRONIC RESPIRATORY FAILURE, BIPAP DEPENDENT' and ulungoth=1 
and record_updated='Yes' and uairway=0 and uairwayothsp=' '&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is a logical expression which will be true if ulungoth = 1, record_updated = "Yes", uairway = 0 and uairwayothsp is missing (empty string). The first part (a non-missing string) is always considered "true".&lt;/P&gt;
&lt;P&gt;The result of a logical expression is numeric and either 0 (false) or 1 (true). If the variable on the left side of the assignment is not already defined, the data step compiler will implicitly define it as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/807202#M318191</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-11T16:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/836457#M330725</link>
      <description>&lt;P&gt;I keep getting an error message every time I run the code. I went over it with my TA and assumed everything was correct but I keep getting error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error message I get;&amp;nbsp;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;Please help the assignment is due tomorrow!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* I am trying to answer question 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is in the editor window:&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname hw3 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3';&lt;BR /&gt;data fit1temp;&lt;BR /&gt;set hw3.fit2;if upcase(compress(smoke)) = "CURRENTSMOKER" then currentsmoker = 1;&lt;BR /&gt;else if upcase(compress(smoke)) = "NONSMOKER" or&lt;BR /&gt;upcase(compress(smoke)) = "FORMERSMOKER" then currentsmoker = 0&lt;BR /&gt;proc freq data=hw3.fit2;&lt;BR /&gt;table blvfx blnspfx;&lt;BR /&gt;if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;&lt;BR /&gt;else if blvfx = "no" and blnspfx = "no" then = any_base_frac = 0;&lt;BR /&gt;if newvfx = "yes" and newnspfx = "yes" then any_new_frac = 1;&lt;BR /&gt;else if newvfx = "no" and newnspfx = "no" then any_new_frac = 0;&lt;BR /&gt;if bmi &amp;gt; 25 then bmi2 = "overweight";&lt;BR /&gt;else if 0 &amp;lt; bmi &amp;lt;= 25 then bmi2 = "normal";&lt;BR /&gt;if 0 &amp;lt; bmi &amp;lt;= 18 then bmi3 = "underweight";&lt;BR /&gt;else if 18 &amp;lt; bmi &amp;lt;= 25 then bmi3 = "normal";&lt;BR /&gt;else if bmi &amp;gt; 25 then bmi3 = "overweight";&lt;/P&gt;&lt;P&gt;bmi1_ind = (bmi &amp;gt; 25);&lt;BR /&gt;bmi2_ind = (18 &amp;lt; bmi &amp;lt;= 25);&lt;BR /&gt;bmi3_ind = (0 &amp;lt; bmi &amp;lt;= 18);&lt;BR /&gt;i_tx = (tx = "Alendronate");&lt;BR /&gt;diff_bmd = cobmd-blbmd;&lt;BR /&gt;age = (dov - dob)/365.25;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 03:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/836457#M330725</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-03T03:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: If statement did not work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/836458#M330726</link>
      <description>&lt;P&gt;Create a new post for your question.&amp;nbsp; Ask the community experts to help you, in additions, insert your code in the SAS code format.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 03:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-did-not-work/m-p/836458#M330726</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-10-03T03:26:33Z</dc:date>
    </item>
  </channel>
</rss>

