BookmarkSubscribeRSS Feed
newtriks
Obsidian | Level 7

Hello, 

I'm trying to run MAGREE, a macro for Fleiss kappa which I found in the SAS library. I'm having issues with following the instructions to enable my code to reference it.

 

I downloaded the macro in TXT format, and then did what I'd thought the instructions indicated:

 

%inc "<C:\Users\Documents\My SAS Files\9.4\SASfusion_25006_13_magree.txt>";

 

But got the following response (from the log)

16 %include "<C:\Users\Djg00019\Documents\My SAS Files\9.4\SASfusion_25006_13_magree.txt>";
ERROR: Invalid physical name.
ERROR: Incorrect %INCLUDE statement will not be executed. There is a syntax error.

 

What am I doing wrong? Any and all help is appreciated. Thanks!

 

9 REPLIES 9
ballardw
Super User

Do you see a difference here:

 

"<C:\Users\Documents\My SAS Files\9.4\SASfusion_25006_13_magree.txt>";

 

"<C:\Users\Djg00019\Documents\My SAS Files\9.4\SASfusion_25006_13_magree.txt>";

 

Personally anything related to code does not go anywhere near the DOCUMENTS folder on my systems.

 

Make sure you have the actual path to your file in any code. Easiest is to use windows explorer or similar file manager, navigate to the folder where the file appears and copy the path out of the space in the top. Copy on where it indicates the folder and then paste that into your code.

 

 

 

 

SASKiwi
PROC Star

I'd also suggest you don't store SAS programs as .TXT files. Use the .SAS file type so you can double click on it to automatically open in your SAS editor.

newtriks
Obsidian | Level 7
Sorry for the dumb questions but I am a true novice. Is changing the extension from .txt to .sas enough, or is there more to it?
Tom
Super User Tom
Super User

@newtriks wrote:
Sorry for the dumb questions but I am a true novice. Is changing the extension from .txt to .sas enough, or is there more to it?

That is more a question for the Operating System you are using to look at files. On a Windows machine you normally associate a particular file extension with a particular application program.  So then when you click to open the file it opens with an application that knows what to do with it.

 

SAS code, like the code to define a macro, would normally be stored in stored in a file with .sas as the extension so that both the operating system and the people looking at the list of files have a good first guess as to what type of file it is.

 

In terms of using the file with SAS it does not really matter is the file has .sas or .txt of .thing_a_ma_jig as the file extension.  The only place where it might matter is if you want to use the SASAUTOS option to point a directory where SAS can look to find program files that define macros.  When you have done that and you submit code that calls a macro that has not yet been defined SAS will look for a file with the same base name as the macro you are trying to call and an extension of .sas.  If it finds such a file it runs that file first (basically it just uses %include) and then it tries to run the macro call you submitted.

Tom
Super User Tom
Super User

I suspect the instructions using <> as a visual indicator of the content you needed to change.  

They should not be part of the quoted filename for the reason that the error message states. Both < and > are not valid characters in a filename (at least not one with out quoting) because they are using for piping standard input and output in both UNIX and DOS.

 

Try:

%inc "C:\Users\Documents\My SAS Files\9.4\SASfusion_25006_13_magree.txt";

 

Also if the you have the SAS code to define the macro it is not a "stored" macro.  It is just a macro (or perhaps just a SAS program with or without a macro definition in it.).  Which is for the best as it will be much easier to work with the actual SAS code instead of a SAS catalog file with a stored compiled macro in it.

 

Patrick
Opal | Level 21

If you get instructions to use syntax like...

%inc "<path and filename>";

...and your actual path is for example c:\sas\Macros\mymacro.sas then you would substitute the template code by..

%inc "c:\sas\Macros\mymacro.sas";

 

Descriptive text in angel brackets is used in the SAS documentation as placeholder for something to be replaced by actual values in your code. 

Syntax Conventions for the SAS Language

Patrick_0-1710986170982.png

 

Inspired by above SAS syntax conventions many people myself included use text in angle brackets in their answers as placeholder for something you need to replace with the value/string that's valid for your environment - even though it's often not 100% in line with the SAS convention that only uses angel brackets for optional arguments.

 

Btw: The convention is to store SAS programs in files with a suffix of .sas (myprog.sas). But if the instructions tell you to use a file with another suffix like .txt then follow these instructions. This might be for educational purposes when it comes to the introduction of the SAS Macro Autocall facility where you will learn why using suffix .sas can be functionally relevant.

newtriks
Obsidian | Level 7

Thank you all for your advice - copying the path from Explorer, angel brackets and .sas extension. These have been remedied and I clearly have other issues. 

The macro is below. Data, Items, Raters and Response are all filled in according to the variables in my dataset. There's clearly more to it than simply highlighting this and hitting "run", because the log just repeats what I've given it and has no other response. As I've said, I am a novice here who is just trying to run somebody else's macro on my dataset. I have no idea of the steps to point this macro to the dataset or whatever else needs taking care of. Step-by-step, like I'm a 4-year-old. That's about the level of my understanding at this point!

Any and all help is appreciated. Thank you all.

 

%macro magree(version,
data=AIFleissKappa; **_last_,; 
items=Questions,
raters=Raters,
response=Levels,
stat=ALL,
alpha=0.05,
weight=, wtparm=,
options=PRINT WEIGHTS NOCOUNTS SUMMARY Z NOFIXRATERONLY NOPERCATEGORY NOWCL NOITEMEFFECTS NORATEREFFECTS
) / minoperator;

%let time = %sysfunc(datetime());
%let _version=3.91;
%if &version ne %then %put NOTE: &sysmacroname macro Version &_version;
%if &data=_last_ %then %let data=&syslast;
%local notesopt;
%let notesopt = %sysfunc(getoption(notes));
%let newchk=1;
%let version=%upcase(&version);
%if %index(&version,DEBUG) %then %do;
options notes mprint
%if %index(&version,DEBUG2) %then mlogic symbolgen;
;
ods select all;
%put _user_;
%end;
%else %do;
%if %index(&version,NOCHK) %then %let newchk=0;
options nonotes nomprint nomlogic nosymbolgen;
ods exclude all;
%end;


/* Check for newer version
======================================================================*/
%if &newchk %then %do;
%let _notfound=0;
filename _ver url 'http://ftp.sas.com/techsup/download/stat/versions.dat'
termstr=crlf;
data _null_;
infile _ver end=_eof;
input name:$15. ver;
if upcase(name)="&sysmacroname" then do;
call symput("_newver",ver); stop;
end;
if _eof then call symput("_notfound",1);
run;
options notes;
%if &syserr ne 0 or &_notfound=1 or &_newver=0 %then
%put NOTE: Unable to check for newer version of &sysmacroname macro.;
%else %if %sysevalf(&_newver > &_version) %then %do;
%put NOTE: A newer version of the &sysmacroname macro is available at;
%put NOTE- this location: http://support.sas.com/ ;
%end;
%if %index(&version,DEBUG)=0 %then options nonotes;;
%end;

 

Tom
Super User Tom
Super User

The %MACRO statement you posted is invalid. 

 

You cannot have those semicolons in the middle of it.  If you want to comment out code in the middle of another statement you need to use block comment, not statement comment.

 

Also you need a comma between every parameter you are defining.  It will be easier to see if you have done that if you place the at the START of the line BEFORE the next parameter instead of at the ragged END of the previous line.

 

If you are going to need the macro to treat IN as a macro operator then you should also specify the delimiter you plan to use in the lists.  You don't show the macro using the IN operator. Personally I prefer to use space as the delimiter in macro code when I can.  And if not then some other characters like ^ that is no likely to be in the value or be significant to the macro processor.

%macro magree
(version
,data=AIFleissKappa /* ; **_last_,; */
,items=Questions
,raters=Raters
,response=Levels
,stat=ALL
,alpha=0.05
,weight=
,wtparm=
,options=PRINT WEIGHTS NOCOUNTS SUMMARY Z NOFIXRATERONLY NOPERCATEGORY NOWCL NOITEMEFFECTS NORATEREFFECTS
) / minoperator mindelimiter=' ' ;

There is no %MEND statement to mark the end of the macro definition.

 

What is the macro supposed to DO?

How do you plan to use it? Where is the CALL to the macro you want to make?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 829 views
  • 4 likes
  • 6 in conversation