BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi

I am new to SAS, so please bear with me. I am trying to use an array to split a 240 character field of death codes into 48 new variables, each with a width of 5 characters .... with a starting position that moves from 1, 6, 11, 16, 21 etc. Alas, my syntax below keeps succumbing to the error message "The array subscript is out of range":

data b;
set a;
array split(48) $ entity1 - entity48;
do i = 1-48;
j = ((i-1)*5)+1;
split(i) = substr(entity_axis_data,j,5);
end;
run;

Any pearls of wisdom would be appreciated immensely.

Janine
2 REPLIES 2
advoss
Quartz | Level 8
Try this:

data b;
set a;
length entity1 - entity48 $5;
array split(48) entity1 - entity48;
do i = 1 to 48;
j = ((i-1)*5)+1;
split(i) = substr(entity_axis_data,j,5);
end;
run;
deleted_user
Not applicable
Ripper! It worked a treat. Many thanks Advoss.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 2 replies
  • 1201 views
  • 0 likes
  • 2 in conversation