Hello,
I am trying to use the GWNBR macro that developed by Alan but , it did not work. Is it because copy paste the code or something else.
please find the Log ouptput below:
6185 %golden(data=gwrmodel,y=dep,x=indp,lat=centdgy,long=centdgx,method=ADAPTIVE1,type=aic,
-
180
6185! gwr=poisson,out=band);
WARNING: Apparent invocation of macro GOLDEN not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
I appreciate any help.
Hi Guys, this is Alan, paper's author. Attached is the SAS macro for GWNBR. Let me know by email (alansilva@unb.br) if you have further questions.
Where's your macro definition?
Did you run that code before your invocation?
Post your full code and log please.
I run the previous attached file first "GWNBR_Alan_SAS_Macro", then run the following code:
data gwrmodel;
input centdgy centdgx Indp dep;
infile cards dlm =' ';
cards;
34.1358 -117.924 10.9692 12
34.1761 -118.315 10.722 8
33.8236 -118.188 10.6537 2
34.1994 -118.535 10.6964 5
34.0669 -117.751 10.952 15
33.9292 -118.21 10.6143 6
34.015 -118.06 10.7066 4
34.0672 -118.226 10.5749 2
34.0833 -118.107 10.9292 6
34.3875 -118.535 10.7737 0
34.0508 -118.454 10.7889 2
33.9236 -118.371 11.3734 3
34.6901 -118.133 11.5754 22
33.8203 -117.913 11.4777 21
33.9261 -117.951 11.6989 4
33.6275 -117.69 10.9151 3
33.6751 -117.927 10.1761 0
33.85 -116.543 10.514 2
34.0103 -117.426 10.6558 8
33.7083 -117.243 10.7527 4
33.925 -116.876 11.8476 12
33.7146 -116.234 11.6559 7
33.674 -117.321 11.5871 26
33.9756 -117.333 10.0677 2
34.1036 -117.629 10.9899 3
34.2439 -117.274 10.3513 2
34.0994 -117.504 10.0889 2
34.1072 -117.274 9.1505 3
34.0667 -117.151 11.0462 10
33.9846 -117.513 10.8081 3
34.2623 -117.189 11.0214 6
34.1439 -117.851 9.798 4
;run;
%golden(data=gwrmodel,y=dep,x=indp,lat=centdgy,long=centdgx,method=ADAPTIVE1,type=aic,gwr=poisson,out=band);
%gwnbr(data=gwrmodel,y=dep,x=indp,lat=centdgy,long=centdgx,h=9.3796134,gwr=poisson,method=ADAPTIVE1,geocod=indp,out=gwr);
/***************/
here is the part of the log:
6237 %golden(data=gwrmodel,y=dep,x=indp,lat=centdgy,long=centdgx,method=ADAPTIVE1,type=aic,gwr=poi
-
180
6237! sson,out=band);
WARNING: Apparent invocation of macro GOLDEN not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
6238 %gwnbr(data=gwrmodel,y=dep,x=indp,lat=centdgy,long=centdgx,h=9.3796134,gwr=poisson,method=ADA
6238! PTIVE1,geocod=indp,out=gwr);
NOTE: IML Ready
NOTE: Line generated by the invoked macro "GWNBR".
11 par=choose(par<1E-10,1E- 10,par);
-
22
76
ERROR 22-322: Syntax error, expecting one of the following: #, ##, &, (|, *, **, +, ',', -, /, //,
:, <, <=, <>, =, >, ><, >=, @, [, ^=, |, ||.
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: Line generated by the invoked macro "GWNBR".
13 hess=choose(abs(hess)<1E
-
Thank you
There's something wrong in your macro definition file (the attached file).
I don't have time to look through it now, but if you review each macro step by step and make sure it compiles properly that will likely solve the issue. Which is pretty much what I'd have to do to find the issue as well....
As I said I just copy paste it from the paper and I am not expert on coding macro.
Thank you for your time and help
When you copy and paste from PDF or WORD it can introduce all sorts of spaces and invisible characters. That's what's causing the issue.
If you literally typed out all the words in the file it would run properly. So copying and pasting the file into a text editor and then checking for invisible characters and/or just selecting each macro definition and running it individually should resolve the issue. Also, check the log thoroughly for errors. That may be a good place to start.
Also, you should understand your code. Always.
On thing of concern is comments in the form of
*print jj bi;
This form of comment has issues when inside a macro definition. Comments should either include a % to indicate a macro comment
%*print jj bi;
or use the
/*print jj bi;*/
One thing that may help you see where your problems come from is to run the macro with the system options mprint mlogic and symbolgen.
option mprint mlogic symbolgen;
%gwnbr ( <parameters>);
Note, when I pasted the text from the attached text file into my editor there appear to be things messing with the format of the code.
For instance I see {some example lines in the middle of a macro}
do while (abs(dpar)>0.001); aux1=aux1+1; if par<0 then par=0.00001; par=choose(par<1E-10,1E- 10,par); g=sum(digamma(par+y)- digamma(par)+log(par)+1-log(par+u)- (par+y)/(par+u)); hess=sum(trigamma(par+y)- trigamma(par)+1/par- 2/(par+u)+(y+par)/((par+u)#(par+u))); hess=choose(abs(hess)<1E- 23,sign(hess)*1E-23,hess); *CONFERIR!!!; hess=choose(hess=0,1E- 23,hess);
Anything that breaks a scientific notation value in the middle concerns me greatly as to what else may be hidden in the history of that text. It looks like something was done to the file that treats - as an end of line marker.
Statment style comments inside of macro definitions work fine and are an excellent way of making a much more readable SAS log when the MPRINT option is used.
MPRINT(mymacro): * Sort data so that groups can be process separately ;
MPRINT(mymacro): proc sort data=have;
MPRINT(mymacro): by group;
MPRINT(mymacro): run;
There are two things that cause trouble for statement style comments.
First is unbalanced quotes. If you try to make a comment like
* Don't forget to sort ;
Then the SAS parser is going to want to find the closing quote before looking for the ending semi-colon. But in general it is a bad idea to have unbalnced quotes, even inside of comments.
The other obscure issue can happen when using SAS/Connect and having a RSUBMIT block send a macro definition to a remote SAS session. The blocking of the code into packets to send to the remote session can get out of synch and cause SAS to get confused about how to tokenize the input stream. It is better to either use autocall for you macros on the remote side or use %INCLUDE on the remote side to define the macro. I am not even sure if this error is limited to using statement style comments in the macro defintion, but it does seem to occur more often when they are used.
dear @ballardw
thanks for your valuable response, exactly when i fixed this issue the code run better than before but, it did not work completely, here is when the macro fails based on the log:
ERROR: (execution) Invalid argument to function.
operation : LGAMMA at line 18830 column 1
operands : _TEM1001
_TEM1001 1 row 1 col (numeric)
0
statement : ASSIGN at line 18830 column 1
traceback : module CV at line 18830 column 1
NOTE: Paused in module CV.
MPRINT(GOLDEN): npar1=res1[3];
ERROR: (execution) Matrix has not been set to a value.
If you copied across page breaks definitely going to add to the issues. If you have Adobe Pro, convert to text file, copy and then paste.
Good Luck!
Hi Guys, this is Alan, paper's author. Attached is the SAS macro for GWNBR. Let me know by email (alansilva@unb.br) if you have further questions.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: