BookmarkSubscribeRSS Feed
MSALKAR
Calcite | Level 5

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.

2 REPLIES 2
Reeza
Super User

%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 🙂

 

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.

 

MSALKAR
Calcite | Level 5

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 1993 views
  • 0 likes
  • 2 in conversation