BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas_lak
Quartz | Level 8

Hi Everyone,

I need help on below requirement.

 

I have list of Names in dataset, Name contains multiple tokens separated by space.

Need to split name field and arrenge in proper format.

 

Ex- Input data.

Sl No Company Name
1 NSDL PVT LTD
2 CIBIL INDIA LIMITED
3 EQUIFAX INTERNATIONAL LTD
4 HIGMMARK PRIVATE LIMITED
5 EXPERIAN LTD

 

Out put should be :- 

Sl No TOKEN
1 NSDL
1 PVT
1 LTD
2 CIBIL
2 INDIA
2 LIMITED
3 EQUIFAX
3 INTERNATIONAL
3 LTD
4 HIGHMARK
4 PRIVATE
4 LIMITED
5 EXPERIAN
5 LTD

 

Thanks in Advance...!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
infile cards truncover expandtabs;
input SlNo	CompanyName $40.;
cards;
1	NSDL PVT LTD
2	CIBIL INDIA LIMITED
3	EQUIFAX INTERNATIONAL LTD
4	HIGMMARK PRIVATE LIMITED
5	EXPERIAN LTD
;
run;
data want;
 set have;
 do i=1 to countw(CompanyName,' ');
  token=scan(CompanyName,i);output;
 end;
 drop i;
run;

View solution in original post

2 REPLIES 2
Ksharp
Super User
data have;
infile cards truncover expandtabs;
input SlNo	CompanyName $40.;
cards;
1	NSDL PVT LTD
2	CIBIL INDIA LIMITED
3	EQUIFAX INTERNATIONAL LTD
4	HIGMMARK PRIVATE LIMITED
5	EXPERIAN LTD
;
run;
data want;
 set have;
 do i=1 to countw(CompanyName,' ');
  token=scan(CompanyName,i);output;
 end;
 drop i;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1672 views
  • 2 likes
  • 2 in conversation