Help using Base SAS procedures

Fairlie decomposiiton method

Reply
Occasional Contributor
Posts: 14

Fairlie decomposiiton method

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

ERROR: Too few variables defined for the dimension(s) specified for the
array varsa.

 

 

How do I solve this error? I am attaching the entire code of Fairlie decomposition. I am working on my thesis and would greatly appreciate any help on this. Thank you.

Super User
Posts: 19,870

Re: Fairlie decomposiiton method

%let vars= &definegroup1 &definegroup2 &definegroup3 &definegroup4 &definegroup5;

 

Why not the 6th group? I suspect that's your error.

 

The following is my opinion - feel free to disregard it all Smiley Happy

 

Also, this is an efficient way to code. You're hardcoding a lot of things that you should be doing dynamically. Why assign the variables to new variables without doing anything to them? And if you're renaming via a prefix there are technically easier ways.

HOWEVER, if you understand this and it works for you, then work with it. 

 

If you're using someone else's code I have two suggestions:

1. Make sure to work through a known example to ensure it gives you the numbers expected.

2. Comment every line or section to ensure you understand the code.

 

Occasional Contributor
Posts: 14

Re: Fairlie decomposiiton method

Hello Reeza, 

Thank you so much. My code works now. Actually I have never worked on stata so I have no idea how it works. And since I need to finish my thesis I do not have the time to learn a new software. I will base of my analysis off this code and try to work with it. I may have some more posts regarding this test and would really appreciate your help. Thank you.

Ask a Question
Discussion stats
  • 2 replies
  • 126 views
  • 0 likes
  • 2 in conversation