@Anurag_Kumar wrote:
I have a dataset with a variable animal type(example). There are 30 animals overall and any row might have any number of animals:
Big cat; Tiny strong dog; White pony
Big cat;
White pony; Small rabbit;
Tiny strong dog; White pony
I need to separate these into as many columns as required for a particular row. There is no restriction of keeping one column for one animal type. I am using the below code but there are multiple rows being generated along with multiple columns and these columns are empty.
data want; set have;
array var(30); <= this defines an array of numeric values so of course a number cannot be "Big cat"
do i=1 to 30; var(i)=scan(Animal,i,";"); end;
run;
Please advise.
SAS EG version: 7.15
Array var(30) $ 25; to create an array of character values able to hold up to 25 characters per value. Set the length as seems appropriate.
... View more