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);
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;
index=(aar-2019)*12 + mdr;
if branche(index) not in ('','') then do;
if ydelser(dream)=('') then spell(dream)="B";
if ydelser(dream)=('') and spell(dream)=('') then spell(dream)="SF";
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
Hope somebody can help, since I can't locate the error
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.
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?
How many variables are in Arrays ydelser . COUNT them. If you do not have at least 135 variable then the expression :
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
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.