<?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 180-322: Statement is not valid or it is used out of proper order. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656502#M22584</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/332933"&gt;@duckypooh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two things:&lt;/P&gt;
&lt;P&gt;- you can use the IF/THEN statement outside a data step. That's why you get some errors in the log. TO avoid this, remove the "RUN;" just after the SET statement&lt;/P&gt;
&lt;P&gt;- another thing is that you need to define a sufficient length fo your categorical variables. Otherwise, they will be set to the length of the first value and it will cause unexpected results (truncation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data import;
	set mcdata.import;
	/*run;  &amp;lt;---- remove run; */
	
	if Preg_Group in ('Miscarriage', 'Normal');
	
	
	length BMI_cat $10.; /* &amp;lt;---- set an appropriate length to avoid truncation */ 
	if BMI &amp;gt; 28 then BMI_cat = 'BMI &amp;gt;28';
	else if 19 &amp;lt;= BMI &amp;lt; 23 then BMI_cat = '19 &amp;lt;=BMI &amp;lt;23';
	else  BMI_cat = 'BMI Other';
	
	length Age_cat $10.; /* &amp;lt;---- set an appropriate length to avoid truncation */ 
	if Age &amp;lt;32 then Age_cat = 'Age &amp;lt;32';
	else if Age &amp;gt;= 32 then Age_cat = 'Age &amp;gt;=32';
	
	ln_Progestrone = log(Progestrone_nmol_L);
	
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 10 Jun 2020 18:06:05 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-06-10T18:06:05Z</dc:date>
    <item>
      <title>ERROR 180-322: Statement is not valid or it is used out of proper order.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656478#M22579</link>
      <description>&lt;P&gt;Hello everyone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a super newbie to SAS and would appreciate your help, in running the code below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duckypooh_0-1591808065757.png" style="width: 610px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42147iF15A48100955541F/image-dimensions/610x325?v=v2" width="610" height="325" role="button" title="duckypooh_0-1591808065757.png" alt="duckypooh_0-1591808065757.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to filter data from the variable: preg_group to include only the miscarriage and normal data, and amongst these data, define new category variables for my BMI and age subsets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when i ran the code, i got this log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duckypooh_1-1591808172776.png" style="width: 627px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42148i6F6195E5008BC360/image-dimensions/627x495?v=v2" width="627" height="495" role="button" title="duckypooh_1-1591808172776.png" alt="duckypooh_1-1591808172776.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TIA everyone! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 16:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656478#M22579</guid>
      <dc:creator>duckypooh</dc:creator>
      <dc:date>2020-06-10T16:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper order.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656480#M22580</link>
      <description>&lt;P&gt;You can't use an IF command outside of a data step. Remove the RUN; after the DATA IMPORT line (because the RUN; statement ends the data step)&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 17:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656480#M22580</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-10T17:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper order.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656481#M22581</link>
      <description>&lt;P&gt;Please do not post code and logs as pictures, because it's unnecessary work for you and makes it harder for us to point out the mistakes.&lt;/P&gt;
&lt;P&gt;Use the &amp;lt;/&amp;gt; button for logs and other text data, and the "little running man" next to it for SAS code. Just copy/paste the text into the windows opened with these buttons.&lt;/P&gt;
&lt;P&gt;You have a RUN statement immediately after the SET statement; this creates a step boundary and ends the DATA step. Therefore the next statements appear in "open code" (outside of a data step), where they are invalid. Remove this unnecessary RUN statement.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 17:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656481#M22581</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-10T17:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper order.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656486#M22582</link>
      <description>&lt;P&gt;Improve your coding style by giving each statement its own line, and even more if a statement consists of several elements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import
  out=
  datafile=
  dbms=
  replace
;
sheet = "........";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and so on. This improves the readability of your code, and makes it easier to debug and maintain. Also see Maxim 12.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 17:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656486#M22582</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-10T17:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper order.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656502#M22584</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/332933"&gt;@duckypooh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two things:&lt;/P&gt;
&lt;P&gt;- you can use the IF/THEN statement outside a data step. That's why you get some errors in the log. TO avoid this, remove the "RUN;" just after the SET statement&lt;/P&gt;
&lt;P&gt;- another thing is that you need to define a sufficient length fo your categorical variables. Otherwise, they will be set to the length of the first value and it will cause unexpected results (truncation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data import;
	set mcdata.import;
	/*run;  &amp;lt;---- remove run; */
	
	if Preg_Group in ('Miscarriage', 'Normal');
	
	
	length BMI_cat $10.; /* &amp;lt;---- set an appropriate length to avoid truncation */ 
	if BMI &amp;gt; 28 then BMI_cat = 'BMI &amp;gt;28';
	else if 19 &amp;lt;= BMI &amp;lt; 23 then BMI_cat = '19 &amp;lt;=BMI &amp;lt;23';
	else  BMI_cat = 'BMI Other';
	
	length Age_cat $10.; /* &amp;lt;---- set an appropriate length to avoid truncation */ 
	if Age &amp;lt;32 then Age_cat = 'Age &amp;lt;32';
	else if Age &amp;gt;= 32 then Age_cat = 'Age &amp;gt;=32';
	
	ln_Progestrone = log(Progestrone_nmol_L);
	
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2020 18:06:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/656502#M22584</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-10T18:06:05Z</dc:date>
    </item>
  </channel>
</rss>

