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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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