<?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: Error Code - If then Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836502#M330743</link>
    <description>thank you sooo much!!! I can't believe it was that simple!</description>
    <pubDate>Mon, 03 Oct 2022 12:05:17 GMT</pubDate>
    <dc:creator>MisterJenn</dc:creator>
    <dc:date>2022-10-03T12:05:17Z</dc:date>
    <item>
      <title>Error Code - If then Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836461#M330728</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;CODE class=""&gt;&lt;/CODE&gt;&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;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Please help the assignment is due today!&lt;CODE class=""&gt;&lt;/CODE&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&lt;BR /&gt;&lt;BR /&gt;libname hw3 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3';
data fit1temp;
set hw3.fit2;
if upcase(compress(smoke)) = "CURRENTSMOKER" then currentsmoker = 1;
else if upcase(compress(smoke)) = "NONSMOKER" or 
upcase(compress(smoke)) = "FORMERSMOKER" then currentsmoker = 0;
if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;
else if blvfx = "no" and blnspfx = "no" then = any_base_frac = 0;
if newvfx = "yes" and newnspfx = "yes" then any_new_frac = 1; 
else if newvfx = "no" and newnspfx = "no" then any_new_frac = 0;
if bmi &amp;gt; 25 then bmi2 = "overweight"; 
else if 0 &amp;lt; bmi &amp;lt;= 25 then bmi2 = "normal";
if 0 &amp;lt; bmi &amp;lt;= 18 then bmi3 = "underweight";
else if 18 &amp;lt; bmi &amp;lt;= 25 then bmi3 = "normal"; 
else if bmi &amp;gt; 25 then bmi3 = "overweight";

bmi1_ind = (bmi &amp;gt; 25);
bmi2_ind = (18 &amp;lt; bmi &amp;lt;= 25);
bmi3_ind = (0 &amp;lt; bmi &amp;lt;= 18);
i_tx = (tx = "Alendronate");
diff_bmd = cobmd-blbmd;
age = (dov - dob)/365.25;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname hw3 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3';
NOTE: Libref HW3 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Week 3
50   data fit1temp;
51   set hw3.fit2;
52   if upcase(compress(smoke)) = "CURRENTSMOKER" then currentsmoker = 1;
53   else if upcase(compress(smoke)) = "NONSMOKER" or
54   upcase(compress(smoke)) = "FORMERSMOKER" then currentsmoker = 0;
55   if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;
56   else if blvfx = "no" and blnspfx = "no" then = any_base_frac = 0;
                                                  -
                                                  180
ERROR 180-322: Statement is not valid or it is used out of proper order.

57   if newvfx = "yes" and newnspfx = "yes" then any_new_frac = 1;
58   else if newvfx = "no" and newnspfx = "no" then any_new_frac = 0;
59   if bmi &amp;gt; 25 then bmi2 = "overweight";
60   else if 0 &amp;lt; bmi &amp;lt;= 25 then bmi2 = "normal";
61   if 0 &amp;lt; bmi &amp;lt;= 18 then bmi3 = "underweight";
62   else if 18 &amp;lt; bmi &amp;lt;= 25 then bmi3 = "normal";
63   else if bmi &amp;gt; 25 then bmi3 = "overweight";
64
65   bmi1_ind = (bmi &amp;gt; 25);
66   bmi2_ind = (18 &amp;lt; bmi &amp;lt;= 25);
67   bmi3_ind = (0 &amp;lt; bmi &amp;lt;= 18);
68   i_tx = (tx = "Alendronate");
69   diff_bmd = cobmd-blbmd;
70   age = (dov - dob)/365.25;
71   run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FIT1TEMP may be incomplete.  When this step was stopped there were 0
         observations and 22 variables.
WARNING: Data set WORK.FIT1TEMP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 11:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836461#M330728</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-03T11:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error Code - If then Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836465#M330730</link>
      <description>&lt;P&gt;You can't insert a PROC FREQ in the middle of a DATA step. The PROC statement would immediately end the data step, if the preceding IF had been properly terminated with a semicolon.&lt;/P&gt;
&lt;P&gt;The data step code following the PROC FREQ without a new DATA statement would then also be invalid.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 04:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836465#M330730</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-03T04:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error Code - If then Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836470#M330732</link>
      <description>&lt;P&gt;And do not post pictures of code and logs.&lt;/P&gt;
&lt;P&gt;Post logs by copy/pasting the text into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Post code in a similar way, but use the "little running man" right next to the indicated button.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 06:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836470#M330732</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-03T06:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error Code - If then Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836476#M330734</link>
      <description>&lt;P&gt;You need to post the SAS log that shows the very first error (and ideally the very first warning) in the SAS log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error you post (proc freq in the middle of a data step) is not reflected in the code you post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a side story: You can use the yrdif() function to calculate the age. This function will also take leap years into account.&amp;nbsp;age=yrdif(dob,dov,'age');&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 07:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836476#M330734</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-10-03T07:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Error Code - If then Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836496#M330739</link>
      <description>&lt;PRE&gt;55   if blvfx = "yes" or blnspfx = "yes" then any_base_frac = 1;
56   else if blvfx = "no" and blnspfx = "no" then = any_base_frac = 0;
                                                  -
                                                  180
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/PRE&gt;
&lt;P&gt;You can't follow THEN with an = sign.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps this is what you meant:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if blvfx = "no" and blnspfx = "no" then any_base_frac = 0;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 11:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836496#M330739</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-03T11:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error Code - If then Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836502#M330743</link>
      <description>thank you sooo much!!! I can't believe it was that simple!</description>
      <pubDate>Mon, 03 Oct 2022 12:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Code-If-then-Statement/m-p/836502#M330743</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-03T12:05:17Z</dc:date>
    </item>
  </channel>
</rss>

