data have;
input x $40.;
call scan(x,1,p1,l1,' ');
call scan(x,-1,p2,l2,' ');
first=substr(x,1,l1);
last=substr(x,p2);
middle=substr(x,l1+1,p2-l1-1);
Cards;
Rama chandra Vikas murthy
V v s lakshman
Siva sanker Prasad Kumar
Guru' Prasad
Guru' raaj gopal govind dasu
;
proc print;run;
Scan() with 1 gets you the first, scan() with -1 the last word.
All others can be extracted in a do loop from 2 to countw() - 1.
data have;
input x $40.;
call scan(x,1,p1,l1,' ');
call scan(x,-1,p2,l2,' ');
first=substr(x,1,l1);
last=substr(x,p2);
middle=substr(x,l1+1,p2-l1-1);
Cards;
Rama chandra Vikas murthy
V v s lakshman
Siva sanker Prasad Kumar
Guru' Prasad
Guru' raaj gopal govind dasu
;
proc print;run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: