Hi All,
I am still somewhat new to using SAS/IML. In executing the code listed below, the &start value is only recognized for non-negative values. Here is the code:
*creates 3-month shut down rule macro;
%macro threemonth(dst,shutdown,stay_acc,exit_acc);
proc iml;
use &dst;
read all var {jun04 jul04 aug04 sep04 oct04 nov04 dec04 jan05 feb05 mar05 apr05 may05 jun05 jul05 aug05 sep05 oct05 nov05 dec05 jan06 feb06 mar06 apr06 may06 jun06 jul06 aug06 sep06 oct06 nov06 dec06 jan07 feb07 mar07 apr07 may07 jun07 jul07 aug07 sep07 oct07 nov07 dec07 jan08 feb08 mar08 apr08 may08 jun08 jul08 aug08 sep08 oct08 nov08 dec08 jan09 feb09 mar09 apr09 may09 jun09 jul09 aug09 sep09 oct09 nov09 dec09 jan10 feb10 mar10 apr10 may10 jun10 jul10 aug10 sep10 oct10 nov10 dec10 jan11 feb11 mar11 apr11 may11 jun11 jul11 aug11 sep11 oct11 nov11 dec11 jan12 feb12 mar12 apr12 may12 jun12 jul12 aug12 sep12 oct12 nov12 dec12 jan13 feb13 mar13 apr13 may13 jun13 jul13 aug13 sep13 oct13 nov13 dec13 jan14 feb14 mar14 apr14 may14 jun14 jul14 aug14 sep14 oct14 nov14 dec14 jan15 feb15 mar15 apr15 may15} into month_prof;
n_months=ncol(month_prof);
n_farms=nrow(month_prof);
profits = j(n_farms,n_months,0);
Theory_exit = j(n_farms,n_months,0);
Theory_stay = j(n_farms,n_months,0);
Real_exit = j(n_farms,n_months,.);
Real_stay = j(n_farms,n_months,.);
Accuracy_stay = j(n_farms,n_months,.);
Accuracy_exit = j(n_farms,n_months,.);
do i=1 to n_farms;
do j=4 to n_months;
profits[i,j]=month_prof[i,j-1]+month_prof[i,j-2]+month_prof[i,j-3];
if ((month_prof[i,j]=0)*(month_prof[i,j-1]^=0))=1 then real_exit[i,j]=1;
if profits[i,j]< &shutdown then theory_exit[i,j]=1;
if real_exit[i,j]=. then theory_exit[i,j]=.;
if month_prof[i,j]^=0 then real_stay[i,j]=1;
if profits[i,j] >= &shutdown then theory_stay[i,j]= 1;
if real_stay[i,j]=. then theory_stay[i,j]=.;
if real_exit[i,j]^=. then accuracy_exit[i,j]=(theory_exit[i,j]=real_exit[i,j]);
if real_stay[i,j]^=. then accuracy_stay[i,j]=(theory_stay[i,j]=real_stay[i,j]);
end;
end;
&acc_stay=accuracy_stay[:];
print &acc_stay &shutdown;
&acc_exit=accuracy_exit[:];
print &acc_exit &shutdown;
quit;
%mend;
*creates macro for 3 month SEARCH from 'start' to 'end' by 'step' of shut-down rule;
%macro threemonthsearch(dst,shutdown,acc_stay,acc_exit,start,end,step);
%do &shutdown=&start %to &end %by &step;
%threemonth(&dst,&shutdown,&acc_stay,&acc_exit);
%end;
%mend;
*Executes macro for 3 month search of shut-down rule;
%threemonthsearch(work.prof,shutdown,prof_3mo_stay,prof_3mo_exit,-6000,6000,1000);
The code executes for for all non-zero steps but does not execute for -6000,-5000,-4000,-3000,-2000,-1000. Any thoughts or suggestions are greatly appreciated.
Another interesting point is that these values are executed when the &shutdown is removed from the print statements.
The error message for those values is:
NOTE: Line generated by the macro variable "SHUTDOWN".
56 -1000
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, ;, (, (|, ',', /, [, {.
ERROR 200-322: The symbol is not recognized and will be ignored.
Thanks!