DATA Step, Macro, Functions and more

create smallest function for character variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

create smallest function for character variables

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


Accepted Solutions
Solution
‎10-23-2011 08:55 AM
Valued Guide
Posts: 2,177

create smallest function for character variables

Posted in reply to BrentFulton

All Replies
Solution
‎10-23-2011 08:55 AM
Valued Guide
Posts: 2,177

create smallest function for character variables

Posted in reply to BrentFulton

Call sortc()

Occasional Contributor
Posts: 14

create smallest function for character variables

Thank you, Peter, that worked well.

-Brent

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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