BookmarkSubscribeRSS Feed
UPRETIGOPI
Obsidian | Level 7

Hi there

 

I have separate adrress fields like Address, City, State and Zipcode but I would like to create a single address fields by combining all these four fields into one field like : 1345 Quail Creek Ln, Alexandria, VA 22039

 

Address                              City                           State               Zipcode

1345 Quail Creek Ln           Alexandria                VA                  22039

4569 Foxhole Drive            Chantilly                    VA                  22033

 

Single address field I want to create is: 1345 Quail Creek Ln, Alexandria, VA 22039

                                                               4569 Foxhole Drive, Chantilly, VA 22033

 

I tried using CATX function like this

New_address = catx(',',Address,City,State,Zipcode); but it resolves into: 1345 Quail Creek LN,Alexandria,VA,22039

How do I insert space between two elements of the address separated by comma and just the space between state and ziocode as I have shown above ? Please help me. Thanks

 

3 REPLIES 3
Reeza
Super User

Put a space in the first parameter.

 

this_works = catx(", ", "first", "second");
put this_works;
UPRETIGOPI
Obsidian | Level 7

Thank you Ballardw. That wroks.

ballardw
Super User

Try:

New_address = catx(',',Address,City,catx(' ',State,Zipcode));

so the State and Zipcode are combined first with a space and thus treated as a single string by the outer CATX. For a somewhat older appearance you could use multiple spaces such as

catx('   ',State,Zipcode)

to have the zipcode a bit further from the state

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1492 views
  • 0 likes
  • 3 in conversation