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.
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;
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;
The code appears to work, but the variable (CODE) is a character variable and I'm getting the error message mentioning numeric data.
Nevermind. I got it to work now. thanks to everyone help.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.