Help using Base SAS procedures

Fairlie decomposition

Occasional Contributor
Posts: 14

Fairlie decomposition

This is my code 

/*fairlie decomposition 2011-2012*/
libname MONIKA "C:\Users\msalkar\Desktop\THESIS-MONIKA";
options obs=max;
options nolabel ls=75 ps=140;
%let numiterations=100;
%let r=2;
%let gendervars=male female;
%let k=12;

%let definegroup1 = MM1W MM2W MM3W;
%let definegroup2 = mahila_mandal VI20;
%let definegroup3 = religion caste;
%let definegroup4 = BHED INCOME occupation;

%let definegroup6 = RO6  LB18;

%let labelgroup1="media_exposure";
%let labelgroup2="social_events";
%let labelgroup3="cultural_influences";
%let labelgroup4="household_factors";
%let labelgroup5="mothers_age/education";

%let labelgroup6 = "TBA";

%let mdefinegroup1 = mMM1W mMM2W mMM3W;
%let mdefinegroup2 = mmahila_mandal mVI20;
%let mdefinegroup3 = mreligion mcaste;
%let mdefinegroup4 = mBHED mINCOME moccupation;
%let mdefinegroup5 = mMOTHERS_EDUCATION mFHEADAGE;

%let mdefinegroup6 = mRO6  mLB18;

%let wdefinegroup1 = wMM1W wMM2W wMM3W;
%let wdefinegroup2 = wmahila_mandal wVI20;
%let wdefinegroup3 = wreligion wcaste;
%let wdefinegroup4 = wBHED wINCOME woccupation;
%let wdefinegroup5 = wMOTHERS_EDUCATION wFHEADAGE;

%let wdefinegroup6 = wRO6  wLB18;

%let vars= &definegroup1 &definegroup2 &definegroup3 &definegroup4 &definegroup5  &definegroup6;
%let mvars= &mdefinegroup1 &mdefinegroup2 &mdefinegroup3 &mdefinegroup4 &mdefinegroup5  &mdefinegroup6;
%let wvars= &wdefinegroup1 &wdefinegroup2 &wdefinegroup3 &wdefinegroup4 &wdefinegroup5  &wdefinegroup6;



data monika.merge2012;
set monika.merge2011;
if y=. or MM1W=. or MM2W=. or MM3W=. or INCOME=. or FHEADAGE=. or VI20=. or mahila_mandal=. or
religion=. or caste=. or occupation=. or mothers_education=. then delete;
if wt=. or wt<=0 then delete;

data monika.regdata;
set monika.merge2012;
if male=1 or female=1; run;

data monika.male (keep=ym wtm &mvars mergeobs);
set monika.merge2012 ;
array varsa(&k) &vars;
array mvarsa(&k) &mvars;
do i=1 to &k;
if male=1 then output; run;

data monika.female (keep=yw wtw &wvars mergeobs);
set monika.merge2012;
array varsa(&k) &vars;
array wvarsa(&k) &wvars;
do i=1 to &k;
if female=1 then output; run;



After running this I do not get an error but in the data set the values of the variables RO6 and LB18 are not seen. Also, in my log window I do not see any errors but I am not get the any output. So i am not sure if my cide is working. I would appreciate your help. Below is the dataset;


Super User
Posts: 19,772

Re: Fairlie decomposition


K is 12. How many variables does your array have?


Occasional Contributor
Posts: 14

Re: Fairlie decomposition

In my actual code i have put K=14, but yet it is not working.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Posts: 7,766

Re: Fairlie decomposition

The variables are not in &mvars, and so are not in the keep list. I guess you mean mRO6 and mLB18.

To recreate your results, we need some example data from merge2011. Please post it in a data step with datalines.

Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 14

Re: Fairlie decomposition

[ Edited ]
Posted in reply to KurtBremser

This is how my dataset merge2011 looks with the two variables. I did not much follow as to how I include the variables RO6 and LB18 in my &mvars.Let me know.



Super User
Posts: 7,766

Re: Fairlie decomposition

Please post it in a data step with datalines.

Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 3 in conversation