BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

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
Calcite | Level 5
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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 428 views
  • 0 likes
  • 2 in conversation