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

Hi,

I have a data with a variable City and that includes Boroughs. I don't want to have Borough in the City and want to take of the Borough from the City. How can I do that? , I used compress but it is not working the way I want the output to be.

 

E.g.

 

City

Albany

Delmar

Troy

Borough of Bronx

Borough of Queens

Borough of Brooklyn

Manhattan

Buffalo

Suffolk

Nassau

 

 

I don't want "Borough of" and only want to display it as Bronx or Queens etc. I have around more than 100 observations with different City names. I can't use 100 if-then statements. Is there a easy way to do this.

 

Thank you

M

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26
want=strip(tranwrd(have,"Borough of",""));

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26
want=strip(tranwrd(have,"Borough of",""));
Malathi13
Obsidian | Level 7

Hi RW9,

I just used tranwrd without strip and it worked perfectly as I wanted and you gave the same with strip. Thank you so much for the answer. This saved me a lot of time and writing a long code.

 

M

srinath3111
Quartz | Level 8

Hi,

 

Here in this case you can even try 

 

want=scan(city,-1);

 

Thanks

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 3215 views
  • 1 like
  • 3 in conversation