BookmarkSubscribeRSS Feed
ALAA1
Obsidian | Level 7

Hi SAS experts

I would like to make a propensity score matching for my cohort study.

I have used the macros of propensity score matching I have used are similar to the macros provided by Mayo clinic but they didn't work with me!!!

The codes are attached.

 

can any one help me with this? it would be appreciated

 

 

4 REPLIES 4
andreas_lds
Jade | Level 19

I hope that you don't expect that anyone reads the unformatted code you have posted, so please edit your post and move all sas code to the window opening when you click on the little-running-man icon. And please don't just move the code to the box, apply proper formatting first.

ALAA1
Obsidian | Level 7
Thank you for your comment.
This is my first time to post codes and I thought it will be formatted after posting I recognised the problem!
I have edited the topic and attached the codes I think this will be more useful.
ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the <> to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the <> icon or attached as text to show exactly what you have and that we can test code against.

 

To make the LOG more meaningful set the system option MPRINT prior to executing any code with macros when things give unexpected results or errors. Then notes, warnings and errors will appear in the log near the code that causes the problem.

And read the log.

 

The macros involved have lots of checks on the macro parameters. Did you see any thing in the log about problems with them?

ALAA1
Obsidian | Level 7

I mean by doesn't work that there is no output and there is error messages.

you can find the log below.

the whole macros ( until 583 %MEND MATCH;) ran and appeared in the log box with black color.

after (584 %match) the error messages appeared.

 

I hope it is clear now

 

  proc means data=&outnmca n mean sum min max; var &mvars;
573           title9'Summary data for NON-matched cases';
574           run;
575           proc means data=&outnmco n mean sum min max; var &mvars;
576           title9'Summary data for NON-matched controls';
577           run;
578           %end;
579        %END;
580     %END;
581      title9; footnote;
582      run;
583  %MEND MATCH;

NOTE: This SAS session is using a registry in WORK.  All changes will be lost at the end
      of this session.
584  %match(case=case1,control=control1,idca=caseid,idco=ctlid,
585                mvars=prac1 pred,maxiter=100000,
586                wts=1 1, dmaxk=0 0.05,out=mtch,ncontls=2,
587                method=greedy, seedco=123456, seedca=234567);

NOTE: DATA statement used (Total process time):
      real time           0.12 seconds
      cpu time            0.00 seconds



NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



NOTE: Variable prac1 is uninitialized.
NOTE: Variable pred is uninitialized.
NOTE: There were 11955 observations read from the data set WORK.CASE1.
NOTE: The data set WORK.__CASE has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      16:94
NOTE: There were 0 observations read from the data set WORK.__CASE.
NOTE: The data set WORK.__CASE has 0 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds



NOTE: Input data set is empty.
NOTE: The data set WORK.__CASE has 0 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds



NOTE: Variable prac1 is uninitialized.
NOTE: Variable pred is uninitialized.
NOTE: There were 65087 observations read from the data set WORK.CONTROL1.
NOTE: The data set WORK.__CONT has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      31:94
NOTE: There were 0 observations read from the data set WORK.__CONT.
NOTE: The data set WORK.__CONT has 0 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


WARNING: Apparent symbolic reference NCO not resolved.
WARNING: Apparent symbolic reference NCA not resolved.
WARNING: Apparent symbolic reference NCA not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a
       numeric operand is required. The condition was: &NCA*2
ERROR: A character operand was found in the %EVAL function or %IF condition where a
       numeric operand is required. The condition was: &NCO < %EVAL(&NCA*&NCONTLS)
ERROR: The macro GREEDY will stop executing.
ERROR: File WORK.MTCH.DATA does not exist.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds

NOTE: Input data set is empty.
NOTE: The data set WORK.__CASE has 0 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

ERROR: File WORK.MTCH.DATA does not exist.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.__NMCA may be incomplete.  When this step was stopped there
         were 0 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds


NOTE: Input data set is empty.
NOTE: The data set WORK.__CONT has 0 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
ERROR: File WORK.MTCH.DATA does not exist.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

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

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.__NMCO may be incomplete.  When this step was stopped there
         were 0 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


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

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



NOTE: Writing HTML Body file: sashtml.htm
ERROR: File WORK.MTCH.DATA does not exist.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.48 seconds
      cpu time            0.12 seconds
ERROR: File WORK.MTCH.DATA does not exist.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds

NOTE: No observations in data set WORK.__NMCA.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.17 seconds
      cpu time            0.00 seconds

NOTE: No observations in data set WORK.__NMCO.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


588
589
590  data mtchall;set mtch;run;
ERROR: File WORK.MTCH.DATA does not exist.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MTCHALL 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.00 seconds
      cpu time            0.00 seconds
593  data mtchcase;set mtchall;
594  rename __IDCA=caseid;
595  keep  __IDCA ;
596  run;

WARNING: The variable __IDCA in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable __IDCA in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 0 observations read from the data set WORK.MTCHALL.
NOTE: The data set WORK.MTCHCASE has 0 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


597  proc sort data=mtchall;by __IDCA;run;
ERROR: Variable __IDCA not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
598
599
600


601  data mtchctl;set mtchall;
602  rename __IDCO=ctlid;
603  keep  __IDCO  ;
604  run;
WARNING: The variable __IDCO in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable __IDCO in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 0 observations read from the data set WORK.MTCHALL.
NOTE: The data set WORK.MTCHCTL has 0 observations and 0 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


605  proc sort data=mtchctl;by ctlid;run;
ERROR: Variable CTLID not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

606


607  proc sort data=case1;by caseid;run;

NOTE: There were 11955 observations read from the data set WORK.CASE1.
NOTE: The data set WORK.CASE1 has 11955 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


608  proc sort data=mtchcase;by caseid;run;
ERROR: Variable CASEID not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

609


610  data mtchcase1;merge mtchcase(in=inmtchcase) case1;
611  by caseid;
612  if inmtchcase;
613  keep chi ;run;
ERROR: BY variable caseid is not on input data set WORK.MTCHCASE.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MTCHCASE1 may be incomplete.  When this step was stopped there
         were 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


614
615  proc sort data=mtchcase1;by chi;run;

NOTE: Input data set is empty.
NOTE: The data set WORK.MTCHCASE1 has 0 observations and 1 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


616  data mtchcase1f;set mtchcase1;
617  by chi;
618  if first.chi;
619  group=1;
620  run;

NOTE: There were 0 observations read from the data set WORK.MTCHCASE1.
NOTE: The data set WORK.MTCHCASE1F has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


621
622
623  proc sort data=control1;by ctlid;run;

NOTE: There were 65087 observations read from the data set WORK.CONTROL1.
NOTE: The data set WORK.CONTROL1 has 65087 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds


624  proc sort data=mtchctl;by ctlid;run;
ERROR: Variable CTLID not found.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



625  data mtchctl1;merge mtchctl(in=inmtchctl) control1;
626  by ctlid;
627  if inmtchctl;
628  keep chi ;
629  run;

ERROR: BY variable ctlid is not on input data set WORK.MTCHCTL.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MTCHCTL1 may be incomplete.  When this step was stopped there
         were 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


630
631  proc sort data=mtchctl1;by chi;run;

NOTE: Input data set is empty.
NOTE: The data set WORK.MTCHCTL1 has 0 observations and 1 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

632  data mtchctl1f;set mtchctl1;
633  by chi;
634  if first.chi;
635  group=0;
636  run;

NOTE: There were 0 observations read from the data set WORK.MTCHCTL1.
NOTE: The data set WORK.MTCHCTL1F has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

638  data mtchfinal;set mtchcase1f mtchctl1f;
639  run;

NOTE: There were 0 observations read from the data set WORK.MTCHCASE1F.
NOTE: There were 0 observations read from the data set WORK.MTCHCTL1F.
NOTE: The data set WORK.MTCHFINAL has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 928 views
  • 0 likes
  • 3 in conversation