BookmarkSubscribeRSS Feed
Louis_hen
Calcite | Level 5

Hi!

I am trying to complete my code for assigning a status on individuals on their labourmarket status. 

My code is the following:

 

data SPECIALE.merge_bf_self (compress=binary);

set SPECIALE.merge_dpsgdp;

 

array ydelser (*) $3 y_1901--y_2130;

array spell (135) $2;

array branche (*) $6 branche_2019_01--branche_2021_07;

 

do i='31dec2018'd to '30jul2021'd;

mdr=month(i);

aar=year(i);

dag=day(i);

ugedag=weekday(i);

 

dream=ceil(((i-'31dec2018'd)+1)/7);

index=0;

index=(aar-2019)*12 + mdr;

 

if branche(index) not in ('','') then do;

if ydelser(dream)=('') then spell(dream)="B";

 

end;

if ydelser(dream)=('') and spell(dream)=('') then spell(dream)="SF";

end;

run;

 

However when I run the code, then there pops an error with the message that array subscript out of range at line 46 column 4

 

My data is contructed in the following way, where the data contains different codes depending on the individuals status

IDy_1901...y_2130branche_2019_01...branche_2021_07spells
1       
2       
3       
4       
5       
6       
...       

 

Hope somebody can help, since I can't locate the error

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Please show us the entire LOG, all of it, every single line, every single character, so we can know what line 46 contains. Do not show us just line 46.

 

Please format the log properly so we can read it easily. You do this by copying the log as text and pasting it into the window that appears when you click on the </> icon here in the SAS Communities. DO NOT SKIP THIS STEP.

 

In the future, whenever there is an error in the log, please follow all of the above instructions.

--
Paige Miller
Tom
Super User Tom
Super User

The log will tell you more information that will help you figure this out.  In particular it should show you which line of code is line # 46 in this session.  It will also show you the values for all of the variables at the time the error was detected.  So check the value of the variables that you used as array indexes.  Also check the value of the _N_ automatic variable to see which observation caused the issue.

 

Sounds like your data is poorly structured for what you want to do.  Your could would probably be a lot simpler if each date was its own observation instead of trying to make so many variables.  To get more help describe what you are trying to do.  What is the source data?  What is the desired output?  Is it a report? A dataset? What will the dataset be used for?  

ballardw
Super User

How many variables are in Arrays ydelser  . COUNT them. If you do not have at least 135 variable  then the expression :

ydelser(dream)

is the culprit when Dream exceeds the number of  variables in the array.

If you don't know the number you can easily check with the DIM function: numelements=dim(arrayname)

Or if Branche actually has fewer than 31 variables

 

 

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 3 replies
  • 334 views
  • 0 likes
  • 4 in conversation