## Using ARRAY and Scan function together

Solved
Occasional Contributor
Posts: 10

# Using ARRAY and Scan function together

Hello, Is it possible to use the Array and scan together. With the current project I'm working on, I'm currently using the scan function to pull individual variable from a column. For example, here an example of a code I wrote out:

data test;

set temp;

CODE1=scan(CODE,1, ' ');

CODE2=scan(CODE,2,' ');

.

.

.CODE27=scan(CODE,27,' ');

run;

Is it possible to used an 'array' function to simplied this code. Thanks.

Accepted Solutions
Solution
‎06-10-2016 02:49 PM
Posts: 5,521

## Re: Using ARRAY and Scan function together

Of course, it is possible

``````data test;
set temp;
array c code1-code27;
do i = 1 to dim(c);
c{i} = scan(CODE, i, ' ');
end;
drop i CODE;
run;``````
PG

All Replies
Solution
‎06-10-2016 02:49 PM
Posts: 5,521

## Re: Using ARRAY and Scan function together

Of course, it is possible

``````data test;
set temp;
array c code1-code27;
do i = 1 to dim(c);
c{i} = scan(CODE, i, ' ');
end;
drop i CODE;
run;``````
PG
Occasional Contributor
Posts: 10

## Re: Using ARRAY and Scan function together

The code appears to work, but the variable (CODE) is a character variable and I'm getting the error message mentioning numeric data.

Occasional Contributor
Posts: 10