BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jdgriffin
Fluorite | Level 6

 First time posting on the discussion boards here (I believe). 

 

I continue to encounter the error: "ERROR: Array subscript out of range at line 61 column 31."

 

The code is as follows:

 

data conversion;
set work.combo2;
array original_variables{7} rawsug refsug HFCS glucose dextrose total totalsweet;
array conversion_variables{7} rawsug_tbsp refsug_tbsp HFCS_tbsp glucose_tbsp dextrose_tbsp total_tbsp totalsweet_tbsp;
do vars= 1-7;
	conversion_variables{vars} = original_variables{vars}/3; /* This is line 61*/
end;
drop vars;
run;

And the exact error message:
 
 
ERROR: Array subscript out of range at line 61 column 31.
 Year=1970 Grains=6.93 Dairy=1.81 Meat_Fish=3.25 Vegetables=3.29 Fruits=1.12 Uspop=205.052 RawSug=37.112167365 RefSug=34.684268565
 HFCS=0.1867832418 Glucose=4.7409189704 Dextrose=1.5663774862 Total=6.4940796983 Syrup=0.1695530355 Honey=0.3424306404
 TotalSweet=41.690331939 rawsug_tbsp=. refsug_tbsp=. HFCS_tbsp=. glucose_tbsp=. dextrose_tbsp=. total_tbsp=. totalsweet_tbsp=.
 vars=-6 _ERROR_=1 _N_=1
 
I'm using an example from Section 13.5 "Learning SAS By Example" as my template and it seems like this should work. is there something I am missing?
 
Thanks for taking the time to review. 
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Looking at the error you can see VARS=-6

 

Your do statement is incorrect and resolves to

 

do vars=1-7 -> do vars=-6

 

You want

 

do vars=1 to 7;

View solution in original post

2 REPLIES 2
Reeza
Super User

Looking at the error you can see VARS=-6

 

Your do statement is incorrect and resolves to

 

do vars=1-7 -> do vars=-6

 

You want

 

do vars=1 to 7;

jdgriffin
Fluorite | Level 6

Thank you for the quick reply. It is much appreciated. 

 

EDIT: That fix worked perfectly!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 824 views
  • 1 like
  • 2 in conversation