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

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

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
PatriciaEilerman
Calcite | Level 5

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

PatriciaEilerman
Calcite | Level 5

Nevermind. I got it to work now. thanks to everyone help.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3870 views
  • 0 likes
  • 2 in conversation