BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tellmeaboutityo
Obsidian | Level 7

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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);

View solution in original post

4 REPLIES 4
Reeza
Super User

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);
tellmeaboutityo
Obsidian | Level 7

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. 

Reeza
Super User

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(......);

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3769 views
  • 0 likes
  • 3 in conversation