I'm not experienced with macros, but I'm trying to run a greedy matching macro on some data. I've tried both of the following macros, only editing the indicated inputs.
Mayo Clinic's version:
https://github.com/Jiangtang/Programming-SAS/blob/master/UserMacros/mayo/gmatch.sas
%MACRO GMATCH(DATA=allscores,GROUP=group,ID=id,
MVARS=prob,WTS=1,DIST=1,
NCONTLS=1,
SEEDCA=33541,SEEDCO=4353451,PRINT=y,
OUT=whatever,OUTNMCO=matched);
And Duke's version:
http://people.duke.edu/~hammill/software/gmatch.sas
%macro gmatch(
inds = allscores,
matchvar = prob,
groupvar = group,
idvar = id,
stratvar = NONE,
caliper = NONE,
caliper_type = ABS,
randseed = -1,
ncntls = 1,
outlinks = OUTLINKS,
outds = OUTMATCH
);
Both versions run without generating errors, but seem to run too quickly to actually be making any computations. No output data sets are produced with either version. I'm suspecting that there is a more general "problem", perhaps with settings, since both macros are published by reputable organizations. Help?
You're calling the macros incorrectly, it shouldn't have the %MACRO word there. You may need to restart SAS first to clear your system and then submit as:
%GMATCH(DATA=allscores,GROUP=group,ID=id,
MVARS=prob,WTS=1,DIST=1,
NCONTLS=1,
SEEDCA=33541,SEEDCO=4353451,PRINT=y,
OUT=whatever,OUTNMCO=matched);
You're calling the macros incorrectly, it shouldn't have the %MACRO word there. You may need to restart SAS first to clear your system and then submit as:
%GMATCH(DATA=allscores,GROUP=group,ID=id,
MVARS=prob,WTS=1,DIST=1,
NCONTLS=1,
SEEDCA=33541,SEEDCO=4353451,PRINT=y,
OUT=whatever,OUTNMCO=matched);
You put me on the right track, thanks!
The full code must be run with %macro GMATCH must first be run to define the macro. Then the code you indicate must run after it, to execute the defined macro.
I prefer to keep the macros stored separately, in their own programs, otherwise they clutter up your analysis.
So the macros are stored in a separate file. You compile the macro by either running that code first manually OR you can use %INCLUDE to include the program.
%include 'path to your gmatch.sas file from CDC/Mayo';
%gmatch(......);
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 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.