jeudi 26 septembre 2019

How to extract middle name from heterogeneous variable with different words count?

I am working in SAS and I have the following dataset from which I need help to extract middle name from heterogeneous variable with different words count? I saw prior link but it does not work for me. my data has only 1 variable

Full_name Ronaldo Al Fisher H. O. Meir Lee Sara Kim Ivan Marco Sina

Manes with first and last names only should be blank in the new column called middle. I tried the following code but it does not work:

> data statisticians; length middle $10;   set statisticians;    if
> count = 2 then middle=.;    if count = 3 then middle= scan(name,2);   
> if count = 4 then middle=scan(name,2);  run;

Any help will be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire