Desktop productivity for business analysts and programmers

gmatch macros don't output data

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

gmatch macros don't output data

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? 


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 20,224

Re: gmatch macros don't output data

Posted in reply to tellmeaboutityo

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


All Replies
Solution
2 weeks ago
Super User
Posts: 20,224

Re: gmatch macros don't output data

Posted in reply to tellmeaboutityo

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);
New Contributor
Posts: 3

Re: gmatch macros don't output data

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. 

Super User
Posts: 20,224

Re: gmatch macros don't output data

Posted in reply to tellmeaboutityo

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(......);
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 110 views
  • 0 likes
  • 2 in conversation