<?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 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/795125#M255011</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415922"&gt;@Cincy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;;*%mend;*);*';*";**/;
run;&lt;/PRE&gt;
&lt;P&gt;I don't know what's wrong with my code. But if I don't put this coding here, the program for data X2 only gives me error (Note 49-169).&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not an ERROR, it's a NOTE, and you can remove it by diligently using blanks to make your code more readable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put '%let ymd=' ymd ';%YmdRun;';&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Feb 2022 09:11:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-02-09T09:11:10Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/794910#M254919</link>
      <description>&lt;P&gt;Hello to SAS professionals,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running a code below, which is shared by my professor. However, the error 180-322 keeps showing after I run the macros, and I cannot find where I did wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The coding within "StkRun" runs without problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data time;
length ymd $8.;
infile "D:\Schedule\Finance 2022\projects\DtaqTxt\DtaqDays.txt" recfm=v;
input ymd;
if _n_=3 then stop;
run;

*read tics;
data sym;
length stk $10.;
infile "D:\Schedule\Finance 2022\projects\DtaqTxt\StkLst.txt" recfm=v;
input stk mrnk;
if _n_=3 then stop;
run;

*set stock macro call file;
data x2;
set time;
file "D:\Schedule\Finance 2022\projects\dataMac.txt";
put '%let ymd='ymd';%YmdRun;';

;*%mend;*);*';*";**/;
run;
*to solve the error of NOTE 49-169*;

data x2;
set Sym;
file "D:\Schedule\Finance 2022\projects\StkMac.txt";
put '%let stk='stk';%let mrnk='mrnk'%StkRun;'

;*%mend;*);*';*";**/;
run;
%macro StkRun;

data temp;
	array exAsk(17) _temporary_;
	array exBid(17) _temporary_;
	array xadpth(17) _temporary_;
	array xbdpth(17) _temporary_;
	length tq $1. oex $1. con $4.;
	exchL="ABCDIJKMNTPSTWXYZ"; 
	*Charater set to ID index number of exchange;
	eps=0.0001;
	*recfm: specifies the record format: v=variable format;
	infile "D:\Schedule\Finance 2022\projects\DtaqTxt\&amp;amp;date\&amp;amp;stk..txt" recfm=v missover;
	input tq tm oex pask vbid con bask bbid adpt bdpt;

	*find best Ask, Bid, and total NBBO depth*;
	if tq='Q' then do;
		Expnt=index(exchL,oex);
		if pask&amp;lt;=0 then
		ExAsk(Expnt)=99999;
		else
		ExAsk(Expnt)=pask;
		ExAsk(Expnt)=pask;
		Exbid(Expnt)=vbid;
		Xadpth(Expnt)=adpt;
		Xbdpth(Expnt)=bdpt;
	end;

	minask=min(of ExAsk[*]);
	maxbid=max(of Exbid[*]);

	do i=1 to 17;
		if (ExAsk(i)&amp;lt;=minask+eps) and (ExAsk(i)&amp;gt;=minask-eps) then
		BaskDpth=BaskDpth+Xadpth(i);
		if (Exbid(i)&amp;lt;=maxbid+eps) and (Exbid(i)&amp;gt;=maxbid-eps) then
		BbidDpth=BbidDpth+xbdpth(i);
	end;
	
	if _n_&amp;gt;25 then stop;
run;

%put ---- stock is &amp;amp;stk;
%mend;

options nonotes;
%macro YmdRun;

%include 'D:\Schedule\Finance 2022\projects\StkMac.txt';

%put ------&amp;amp;ymd;

%mend;

%include 'D:\Schedule\Finance 2022\projects\dataMac.txt';&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 02:39:03 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/794910#M254919</guid>
      <dc:creator>Cincy</dc:creator>
      <dc:date>2022-02-08T02:39:03Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/794911#M254920</link>
      <description>&lt;P&gt;This step doesn't make any sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*set stock macro call file;
data x2;
set time;
file "D:\Schedule\Finance 2022\projects\dataMac.txt";
put '%let ymd='ymd';%YmdRun;';

;*%mend;*);*';*";**/;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First get rid of the gibberish at the end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now look at the PUT statement.&amp;nbsp; You are writing a string that you are bounding with single quotes.&amp;nbsp; But you appear to placing single quotes in the string itself.&amp;nbsp; In that case you need to double the single quotes so SAS knows they are part of the string and marking the boundaries of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x2;
  set time;
  file "D:\Schedule\Finance 2022\projects\dataMac.txt";
  put '%let ymd=''ymd'';%YmdRun;';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So it looks like you are trying to write this code to a file.&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=" language-sas"&gt;%let ymd='ymd';%YmdRun;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That does seem strange.&amp;nbsp; Why do you want the single quotes in the value of YMD macro variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the bigger picture it kind of looks like you are trying to read something in from a text file and pass it to a macro to use.&amp;nbsp; Notice how your first two data steps are creating &lt;STRONG&gt;actual&lt;/STRONG&gt; dataset &lt;STRONG&gt;variables&lt;/STRONG&gt; named YMD, STK and MRNK.&amp;nbsp; And then the other steps seem to be trying to write out SAS code to create &lt;STRONG&gt;macro variables&lt;/STRONG&gt; that use the same names as the dataset variables.&amp;nbsp; So it kind of looks like you want to copy the value read from the text file into the macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case perhaps your PUT statement should be more like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; put '%let ' ymd= ';' 
    / '%YmdRun;'
  ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This tells SAS to write the string '%let ' (notice the trailing space) then the value of the variable YMD prefixed by its name and an equal sign then a semi-colon and on a new line a call to the macro YMDRUN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the long run it will probably be better to just write your macros to take their input as &lt;STRONG&gt;PARAMETERS&lt;/STRONG&gt; instead of depending on some external macro variable being defined before the macro starts running.&lt;/P&gt;
&lt;P&gt;So perhaps something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro StkRun
(date   /* date string to use in forming the filename */
,stk    /* sticker code to use in forming the filename */
);
%put ---- date is &amp;amp;date;
%put ---- stock is &amp;amp;stk;

data temp;
  array exAsk(17) _temporary_;
  array exBid(17) _temporary_;
  array xadpth(17) _temporary_;
  array xbdpth(17) _temporary_;
  length tq $1. oex $1. con $4.;
  exchL="ABCDIJKMNTPSTWXYZ"; 
  *Charater set to ID index number of exchange;
  eps=0.0001;
  *recfm: specifies the record format: v=variable format;
  infile "D:\Schedule\Finance 2022\projects\DtaqTxt\&amp;amp;date\&amp;amp;stk..txt" recfm=v TRUNCOVER;
  input tq tm oex pask vbid con bask bbid adpt bdpt;

  *find best Ask, Bid, and total NBBO depth*;
  if tq='Q' then do;
    Expnt=index(exchL,oex);
    if pask&amp;lt;=0 then ExAsk(Expnt)=99999;
    else ExAsk(Expnt)=pask;
    ExAsk(Expnt)=pask;
    Exbid(Expnt)=vbid;
    Xadpth(Expnt)=adpt;
    Xbdpth(Expnt)=bdpt;
  end;

  minask=min(of ExAsk[*]);
  maxbid=max(of Exbid[*]);

  do i=1 to 17;
    if (ExAsk(i)&amp;lt;=minask+eps) and (ExAsk(i)&amp;gt;=minask-eps) then BaskDpth=BaskDpth+Xadpth(i);
    if (Exbid(i)&amp;lt;=maxbid+eps) and (Exbid(i)&amp;gt;=maxbid-eps) then BbidDpth=BbidDpth+xbdpth(i);
  end;

  if _n_&amp;gt;25 then stop;
run;
%mend StkRun;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then your data step might be able to generate the macro call like this instead. It is not clear where the current code is getting the value of the DATE macro variable so let's just tell it to use the value of whatever DATE macro variable already exists as the value for the DATE parameter to the macro.&amp;nbsp; I am not sure what the other variable read in the step that reads STK is for as it is not used by the STKRUN macro.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put '%stkrun(date=&amp;amp;date,' stk = ');' ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 03:11:51 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/794911#M254920</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-08T03:11:51Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/794936#M254937</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x2;
set time;
file "D:\Schedule\Finance 2022\projects\dataMac.txt";
put '%let ymd='ymd';%YmdRun;';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It does make sense if ymd is a variable in dataset TIME. The file would then contain a series of setting a macro variable and calling the macro.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 07:46:58 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/794936#M254937</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-08T07:46:58Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/794966#M254955</link>
      <description>&lt;P&gt;So it is the INCLUDE file with Datamac that errs?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using the SOURCE2 option on the %include statement, so you can see the code submitted, and set the MPRINT option, so you can see the code generated by the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
%include 'D:\Schedule\Finance 2022\projects\dataMac.txt' /source2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 11:06:19 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/794966#M254955</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-02-08T11:06:19Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/795123#M255009</link>
      <description>Thank you!&lt;BR /&gt;I figure it out!</description>
      <pubDate>Wed, 09 Feb 2022 08:54:25 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/795123#M255009</guid>
      <dc:creator>Cincy</dc:creator>
      <dc:date>2022-02-09T08:54:25Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/795124#M255010</link>
      <description>&lt;PRE&gt;;*%mend;*);*';*";**/;
run;&lt;/PRE&gt;&lt;P&gt;I don't know what's wrong with my code. But if I don't put this coding here, the program for data X2 only gives me error (Note 49-169).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 08:56:48 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/795124#M255010</guid>
      <dc:creator>Cincy</dc:creator>
      <dc:date>2022-02-09T08:56:48Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/795125#M255011</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/415922"&gt;@Cincy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;;*%mend;*);*';*";**/;
run;&lt;/PRE&gt;
&lt;P&gt;I don't know what's wrong with my code. But if I don't put this coding here, the program for data X2 only gives me error (Note 49-169).&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not an ERROR, it's a NOTE, and you can remove it by diligently using blanks to make your code more readable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put '%let ymd=' ymd ';%YmdRun;';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 09:11:10 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/795125#M255011</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-09T09:11:10Z</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/SAS-Programming/ERROR-180-322-Statement-is-not-valid-or-it-is-used-out-of-proper/m-p/795336#M255095</link>
      <description>You should probably mark my answer as a solution, then &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 09 Feb 2022 21:08:07 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/795336#M255095</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-02-09T21:08:07Z</dc:date>
    </item>
  </channel>
</rss>

