<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445431#M111618</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The error message itself is pretty clear and you'll get it if you either use a SAS statement that doesn't exist or if there has been an error right before your statement which "confused" the compiler so it can't recognize the valid statement anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using SAS Macro language then basically the SAS Macro generates SAS code and then the SAS code gets compiled and executed. So if the macro generates wrong SAS code then you can get such an error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having said all of the above: I couldn't really see something wrong in your code so I had to create some sample data and run it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...the reason why things are not working for you:&lt;/P&gt;
&lt;P&gt;You define the macro without parameters and without a bracket BUT you call it with a bracket. To avoid the error either use brackets or don't (I prefer using brackets always).&lt;/P&gt;
&lt;P&gt;So to fix your code the only thing you need to do is to change your macro definition as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro write_dx();&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Mar 2018 10:08:05 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-03-14T10:08:05Z</dc:date>
    <item>
      <title>ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445393#M111599</link>
      <description>&lt;P&gt;I have searched some info about this error,but it seems none match mine,may someone familiar with this error take a look.&lt;/P&gt;&lt;P&gt;"Code generated by a SAS macro, or submitted with a "submit selected" operation in your editor, can leave off a semicolon inadvertently." it is still abstruse for me to explore in my code by this comment.may someone give any advice..thanks!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let cnt=500;&lt;BR /&gt;%let dataset=fund_sellList;&lt;BR /&gt;%let sclj='~/task_out_szfh/fundSale/';&lt;BR /&gt;%let wjm='sz_fundSale_';&lt;BR /&gt;&lt;BR /&gt;%macro write_dx;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;options spool;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cur_date=put(today(),yymmdd10.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cur_date=compress(cur_date,'-');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cnt=&amp;amp;cnt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set &amp;amp;dataset;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if _n_=1 then i=cnt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if _n_&amp;lt;=i then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;abs_filename=&amp;amp;sclj.||&amp;amp;wjm.||cur_date||'.dat';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;abs_filename=compress(abs_filename,'');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;file anyname filevar=abs_filename encoding='utf8' nobom ls=32767 DLM='|';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put cst_id @;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put '@|' @;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put cust_name @;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put '@|' ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;run;&lt;BR /&gt;%mend write_dx;&lt;BR /&gt;&lt;BR /&gt;%write_dx();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and if I am not using macro,there is no error.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;options spool;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cur_date=put(today(),yymmdd10.);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cur_date=compress(cur_date,'-');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cnt=&amp;amp;cnt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set &amp;amp;dataset;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if _n_=1 then i=cnt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if _n_&amp;lt;=i then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;abs_filename=&amp;amp;sclj.||&amp;amp;wjm.||cur_date||'.dat';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;abs_filename=compress(abs_filename,'');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;file anyname filevar=abs_filename encoding='utf8' nobom ls=32767 DLM='|';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put cst_id @;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put '@|' @;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put cust_name @;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put '@|' ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;run;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 07:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445393#M111599</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-14T07:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445397#M111601</link>
      <description>&lt;P&gt;Get your SAS code to run properly before wrapping it in a macro.&lt;/P&gt;
&lt;P&gt;Since your macro has no macro-specific code, and uses no macro parameters, it is not needed anyway.&lt;/P&gt;
&lt;P&gt;Removing the macro definition will enable the syntax coloration of your Studio or Enterprise Guide, and looking at the log will show you that SAS complains about&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;comress&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in line&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cur_date=comress(cur_date,'-');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is not a SAS function. I guess you wanted to use compress().&lt;/P&gt;
&lt;P&gt;And you don't need compress at all if you use the proper format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cur_date = put(today(),yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 07:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445397#M111601</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-14T07:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445402#M111603</link>
      <description>sorry it's cacography,my code on the server is using "compress"</description>
      <pubDate>Wed, 14 Mar 2018 07:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445402#M111603</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-14T07:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445406#M111605</link>
      <description>&lt;P&gt;Then copy/paste the log as described in &lt;A href="https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce" target="_blank"&gt;https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 07:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445406#M111605</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-14T07:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445408#M111606</link>
      <description>sorry,for the whole log is on my server and can not connect to Internet.So I could only type letter by letter..the only message is this error..</description>
      <pubDate>Wed, 14 Mar 2018 08:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445408#M111606</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-14T08:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445411#M111607</link>
      <description>&lt;P&gt;Open the log window.&lt;/P&gt;
&lt;P&gt;Mark the relevant section.&lt;/P&gt;
&lt;P&gt;Hit Ctrl-C.&lt;/P&gt;
&lt;P&gt;Switch to the browser, hit Ctrl-V.&lt;/P&gt;
&lt;P&gt;Any text displayed in Windows can be copy/pasted that way.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 08:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445411#M111607</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-14T08:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445423#M111614</link>
      <description>thank you for your patience..I mean we use intranet..</description>
      <pubDate>Wed, 14 Mar 2018 09:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445423#M111614</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-14T09:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445428#M111615</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Try removing  the parentheses in the macro call :&lt;BR /&gt;%write_dx;</description>
      <pubDate>Wed, 14 Mar 2018 10:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445428#M111615</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-03-14T10:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445429#M111616</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt; wrote:&lt;BR /&gt;thank you for your patience..I mean we use intranet..&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Text on your screen can be copy/pasted. I guess your intranet is not sending you stone plates with text chiseled in.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 10:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445429#M111616</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-14T10:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445431#M111618</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184018"&gt;@Geo-&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;The error message itself is pretty clear and you'll get it if you either use a SAS statement that doesn't exist or if there has been an error right before your statement which "confused" the compiler so it can't recognize the valid statement anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using SAS Macro language then basically the SAS Macro generates SAS code and then the SAS code gets compiled and executed. So if the macro generates wrong SAS code then you can get such an error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having said all of the above: I couldn't really see something wrong in your code so I had to create some sample data and run it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...the reason why things are not working for you:&lt;/P&gt;
&lt;P&gt;You define the macro without parameters and without a bracket BUT you call it with a bracket. To avoid the error either use brackets or don't (I prefer using brackets always).&lt;/P&gt;
&lt;P&gt;So to fix your code the only thing you need to do is to change your macro definition as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro write_dx();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 10:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445431#M111618</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-14T10:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445461#M111624</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when not using&amp;nbsp;macro parameters, add brackets to the macro name definition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro write_dx();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;or remove the brackets in the macro call&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%write_dx;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to fix the error. I prefer for my part option 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 12:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445461#M111624</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-03-14T12:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 180-322: Statement is not valid or it is used out of proper</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445671#M111712</link>
      <description>thank you!both of your answers pointed out</description>
      <pubDate>Wed, 14 Mar 2018 23:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/445671#M111712</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-14T23:52:35Z</dc:date>
    </item>
  </channel>
</rss>

