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

Dear SAS Community,

I have 3 character variables that I would like to concatenate, but prior to doing that, I want to sort them. My original dataset is id, v1, v2, v3. I would like to create the new variables concat_unsort and concat_sort below. I tried using the "smallest" function, but it tried to change my character variables into a numeric.

I'd appreciate your help.

Thanks,

Brent Fulton

UC Berkeley

data

id     v1     v2     v3     concat_unsort     concat_sort

1      aa    bb     cc     aabbcc               aabbcc

2      aa    cc     bb     aaccbb               aabbcc

3     01     02     03     010203               010203

4     01     03     02     010302               010203

sometimes v1...v3 may contain both letters and numbers e.g., a1

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
Peter_C
Rhodochrosite | Level 12

Call sortc()

BrentFulton
Calcite | Level 5

Thank you, Peter, that worked well.

-Brent

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