N: 1 Propensity score matching help

Reply
Learner
Posts: 1

N: 1 Propensity score matching help

I used the following (http://pharmasug.org/proceedings/2015/HA/PharmaSUG-2015-HA05.pdf)

 

sas macro to implement N:1 propensity score matching. How do I correct the problem in this sas macro? I olny made changes

on:  

 

/********************************************************************/ /* Separate patients treated with the drug from untreated patients /********************************************************************/ DATA prop_score_treated prop_score_untreated; set propensity_scores; if drug_treat_flag = 1 then output prop_score_treated; else if drug_treat_flag = 0 then output prop_score_untreated; run;

 

*********************************************************************/ /* 2:1 Matching with an absolute difference between propensity scores /* of 0.05 /************************************************************************/ %psmatch_multi(pat_dsn = prop_score_treated, pat_idvar = pat_id, pat_psvar = prob_treat, cntl_dsn = prop_score_untreated, cntl_idvar = pat_id, cntl_psvar = prob_treat, match_dsn = matched_pairs2, match_ratio = 2, score_diff = 0.05);

 

but sas returns with the following error messages

ERROR: Argument 1 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC

       macro function is not a number.

ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC

       argument list.  Execution of %SYSCALL statement or %SYSFUNC or

       %QSYSFUNC function reference is terminated.

ERROR: Argument 1 to function VARTYPE referenced by the %SYSFUNC or

       %QSYSFUNC macro function is not a number.

ERROR: Argument 2 to function VARTYPE referenced by the %SYSFUNC or

       %QSYSFUNC macro function is not a number.

ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC

       argument list.  Execution of %SYSCALL statement or %SYSFUNC or

       %QSYSFUNC function reference is terminated.

ERROR: Argument 1 to function CLOSE referenced by the %SYSFUNC or %QSYSFUNC

       macro function is not a number.

ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC

       argument list.  Execution of %SYSCALL statement or %SYSFUNC or

       %QSYSFUNC function reference is terminated.

& cntl_type

ERROR: File WORK.PROP_SCORE_TREATED.DATA does not exist.

 

WARNING: The variable linkid in the DROP, KEEP, or RENAME list has never

         been referenced.

WARNING: The variable prob_treat in the DROP, KEEP, or RENAME list has never

         been referenced.

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.PATMATCH may be incomplete.  When this step was

         stopped there were 0 observations and 0 variables.

NOTE: DATA statement used (Total process time):

      real time           0.16 seconds

      cpu time            0.03 seconds

 

 

 

NOTE: Line generated by the invoked macro "PSMATCH_MULTI".

3                                                                         A

                                                                          -

                                                                          180

3   ! General SAS® Macro to Implement Optimal N:1 Propensity Score Matching

3   ! Within a Maximum Radius , continued 8   DATA contmatch (keep =

3   ! &cntl_idvar &cntl_psvar); set &cntl_dsn; run;   PROC

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

NOTE: Line generated by the invoked macro "PSMATCH_MULTI".

3        DATA patmatch (keep = &pat_idvar &pat_psvar); set &pat_dsn; run; A

3   ! General SAS® Macro to Implement Optimal N:1 Propensity Score Matching

3   ! Within a Maximum Radius , continued 8   DATA contmatch (keep =

3   ! &cntl_idvar &cntl_psvar); set &cntl_dsn; run;   PROC

                                ---

                                180

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

 

NOTE: Line generated by the macro variable "CNTL_PSVAR".

1      c.prob_treat

       -

       78

       76

ERROR 78-322: Expecting a ','.

 

ERROR 76-322: Syntax error, statement will be ignored.

 

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.34 seconds

      cpu time            0.04 seconds

 

 

ERROR: File WORK.MATCHES0.DATA does not exist.

ERROR: A character operand was found in the %EVAL function or %IF condition

       where a numeric operand is required. The condition was: & cntl_type =

       C

ERROR: The macro PSMATCH_MULTI will stop executing.

 

 

I appreciate your help, 

Selam

 

Super User
Posts: 11,105

Re: N: 1 Propensity score matching help

Run your code with the OPTION MPRINT turned on to see the code generated by the macro. The error messages will then usually display close the lines of code that cause them.

Resolve the first error message first. Often many messages arrise from one error or you have repeated the same error in many places.

 

Your first error:

ERROR: Argument 1 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC

       macro function is not a number.

indicates that you are using the function VARNUM on something that is not numeric. Since you say you were attempting to change to N:1 it may be that what is referenced in the VARNUM is multiple values or variables instead of a single value/variable.

Ask a Question
Discussion stats
  • 1 reply
  • 308 views
  • 0 likes
  • 2 in conversation