0

I am new to SAS and i am trying to split columns and give the splitted results new names. What i hope to achieve: for example I have a column AV. My code needs to split it and calls the two new columns FROM_AV and TO_AV. I have tried multiple options, but it is still going wrong by creating the new names. i. It would be great if someone could help me out.

set work.transposed;
array aresplit AV TD ER PT;
do i=1 to 4;
FROM&aresplit[i]= scan(aresplit[i],1,',');
TO&aresplit[i]= scan(aresplit[i],2,','); 
end;
run;```
1
  • Yo don't seem to be trying to reference any of those variable names in that code. What is the macro variable ARESPLIT? What value does it have? Where are the arrays that you are trying to reference defined whose array names include the value of that undefined macro variable? Commented Dec 21, 2019 at 15:28

1 Answer 1

1

To make FROM_AV and TO_AV from AV you would use code like:

FROM_AV = scan(AV,1,',');
TO_AV = scan(AV,2,','); 

If you want to replicate that for four variables using arrays then you need three arrays. One for input variable list and two for the output variable lists. (or the out array could be two dimensional).

array in AV TD ER PT;
array out1  FROM_AV FROM_TD FROM_ER FROM_PT;
array out2  TO_AV TO_TD TO_ER TO_PT;
do index=1 to dim(in);
   out1[index] = scan(in[index],1,',');
   out2[index] = scan(in[index],2,',');
end;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.