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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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