BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

industry

ashok industries pvt ltd

sai industries limited

a&b&c  industries Ltd.

x&y&z industries ltd

chaitinya industries Pvt. Ltd.

(sathya sai industries) Co.Ltd

sai harsha industries (Pvt.Ltd)

 

if you observe above dataset every record has one extenstion name like 'pvt ltd', 'ltd','limited' so 

how can we remove that extenstion name and '%' like see beow dataset 

 

industry

ashok industries%

sai industries%

a&b&c  industries%

x&y&z industries%

chaitinya industries%

(sathya sai industries)%

sai harsha industries%

2 REPLIES 2
thanikondharish
Fluorite | Level 6
i created one dataset (possible values) i want to know postion of the extenstion name so i wrote one program but i am getting only one record once check the code data ext ; input ext$ ; cards ; pvt ltd limited Ltd. ltd pvt.Ltd Co.lLtd (Pvt.Ltd) ; proc sql ; select count(*) into:count from ext ; select upcase(ext) into:ext1-:ext%left(&count) from ext ; quit; %put &ext1 &ext2 ; data ex2 ; set ex1 ; a=reverse(compbl(industry)) ; run; proc sort data=ex2 out=ex3 ;by a ;run; data ex4; set ex3 ; b=left(reverse(a)) ; drop a industry ;rename b=industry ; run; %macro ex1 ; data ex5 ; set ex4 ; %do i=1 %to &count ; new=find(upcase(industry),"&&ext&i.") ; %end; run; %mend; %ex1 ;
ballardw
Super User

Readability of code is only one reason we have pointed out that code should be pasted into a code box opened with the forum's {I} or "running man" icon.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 909 views
  • 0 likes
  • 2 in conversation