SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
lioradam
Obsidian | Level 7

Hello all,

I wrote the code for Matching with Replacement as in the following  Example 98.6 from the SAS User's Guide:

 

proc psmatch data=School region=allobs(psmin=0.05);

   class Music Gender;

   psmodel Music(Treated='Yes')= Gender Absence;

   match method=replace(k=1) distance=ps exact=Gender caliper=.

         nmatchmost=6;

   assess ps var=(Gender Absence);

   output out(obs=match)=outex6 matchid=_MatchID;

run;

 

and I get the error message:

ERROR: The support region does not exist.

 

I try to change the region to psmin=0.01 or psmin=0.001 but I keep getting the same error message.

Could anyone please advise what I'm doing wrong?

 

Thanks.

Lior

3 REPLIES 3
ghosh
Barite | Level 11

It ran fine when I created the school dataset using the code referenced in the example.  see here

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_code_psmchex4.htm

lioradam
Obsidian | Level 7

Hi,

In my data, it didn't work...

I thought that if I reduce the "psmin"  to be close to zero, I should avoid this error message, but it didn't work...

when I use a different type of matching: "Greedy Nearest Neighbor Matching" it works fine. so I believe there is no problem with my data, but maybe I don't understand how code works.

 

Thanks,

Lior

 

ghosh
Barite | Level 11

I ran your code after creating the school dataset from the example and did not get any errors


ghosh_0-1662825726201.png
data School;
   Music= 'Yes';
   do j=1 to 60;
      if (ranuni(1312) > 0.4) then Gender='Female';
      else                         Gender='Male';

      Absence = ranexp(99);
      if (Absence < 0.5) then GPA= 4 + rannor(99)/3.5;
      else                    GPA= 4 - abs(rannor(99)/3.5);

      if (Gender='Female') then GPA= GPA + 0.02;

      id1= ranuni(99);
      id2= ranuni(99);
      output;
   end;

   Music= 'No';
   do j=1 to 100;

      Absence= ranexp(99);
      if (ranuni(99) > 0.45) then Gender='Female';
      else                        Gender='Male';
      if (Absence < 0.5) then GPA= 4 + rannor(99)/4.2;
      else                    GPA= 4 - abs(rannor(99)/4.2);

      id1= ranuni(99);
      id2= ranuni(99);
      output;
   end;

   do j=1 to 40;
      Absence= 2 + ranexp(99);
      if (ranuni(99) > 0.5) then Gender='Female';
      else                       Gender='Male';

      GPA= 3.4 - abs(rannor(99)/4.2);

      id1= ranuni(99);
      id2= ranuni(99);
      output;
   end;
run;

proc sort data=school;
   by id1;
run;

data school;
   set school;
   StudentID= _n_;
   Absence= int(Absence*100+0.5) / 100;
   GPA= int(GPA*100+0.5) / 100;
run;

proc sort data=school;
   by id2;
run;

proc print data=School(obs=10);
   var StudentID Music Gender Absence;
run;

proc psmatch data=School region=allobs(psmin=0.05);
   class Music Gender;
   psmodel Music(Treated='Yes')= Gender Absence;
   match method=replace(k=1) distance=ps exact=Gender caliper=.
         nmatchmost=6;
   assess ps var=(Gender Absence);
   output out(obs=match)=outex6 matchid=_MatchID;
run;

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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