DATA Step, Macro, Functions and more

URGENT - Need to split and arrenge in required format - in SAS

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

URGENT - Need to split and arrenge in required format - in SAS

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...!


Accepted Solutions
Solution
‎12-23-2015 10:06 PM
Super User
Posts: 10,023

Re: URGENT - Need to split and arrenge in required format - in SAS

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


All Replies
Solution
‎12-23-2015 10:06 PM
Super User
Posts: 10,023

Re: URGENT - Need to split and arrenge in required format - in SAS

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;
Contributor
Posts: 46

Re: URGENT - Need to split and arrenge in required format - in SAS

Thank you..!
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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