Hi I have one doubt in sas How to split string into multiple columns in sas? Here before first space value consider as firstname and last space after values consider as lastname and between first and lastspace values consider as middle name.
data my_data1;
input name $500.;
datalines;
Andy Lincoln Bernard ravni
Barry Michael
Chad Simpson Smith
Eric
Frank Giovanni Goodwill
;
run;
proc print data=my_data1;
based on data expecte out like below :
Fname | Middlename | lname
Andy | Lincoln Bernard |ravni
Barry | |Michael
Chad | Simpson |Smith
Eric | |
Frank|Giovanni |Goodwill
I tried like below
data my_data2;
set my_data1;
Fname=scan(name, 1, ' ');
Middlename=scan(name, 2, ' ');
Lname=scan(name, -1, ' ');
run;
proc print data=my_data2;
above logic not give expected out put.
can you please tell me how to write code achive this task in sas
