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
want=strip(tranwrd(have,"Borough of",""));
want=strip(tranwrd(have,"Borough of",""));
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
Hi,
Here in this case you can even try
want=scan(city,-1);
Thanks
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.