BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
1800bigk
Fluorite | Level 6

I have 4 variables that I am trying to combine into one but each thing I try is not giving me the result I want.  Here are my entries 20,1,6312468,1 and I want to combine them to get 2016312468 but every time I try something I get 20 space 1 space 6312468 space 1.  I have tried cat, catt, catx and trim each one then use !! to combine and each time it returns the spaces.  Any thoughts?   

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Use strip rather than trim.  E.g.,

data have;

  w=20;

  x=1;

  y=6312468;

  z=1;

  want=cat(strip(w),

           strip(x),

           strip(y),

           strip(z));

run;

View solution in original post

6 REPLIES 6
NN
Quartz | Level 8 NN
Quartz | Level 8

would compress keeping your numeric values not work?

compress(column,'0123456789','k')

art297
Opal | Level 21

Use strip rather than trim.  E.g.,

data have;

  w=20;

  x=1;

  y=6312468;

  z=1;

  want=cat(strip(w),

           strip(x),

           strip(y),

           strip(z));

run;

1800bigk
Fluorite | Level 6

Both of these work thanks for the fast response!

data_null__
Jade | Level 19

How about CATS?

Peter_C
Rhodochrosite | Level 12

data_null_; is providing the correct answer, because CATS() performs the STRIP() and the concatenation

e.g.

want = cats( of w x y z  );

(not even those commas needed when the list is preceeded with OF )

art297
Opal | Level 21

Peter, Of course data_null_ is correct .. as he virtually always is!  However, the other responses were also correct.  For the fun of it I ran a one trial test on 1 million identical records.  I stopped at one test as I happened to like the results: my proposed method came in first (cpu: 1.01 seconds), data_null_'s second (cpu: 1.04 seconds), and your suggestion third (cpu: 1.14 seconds).  Of course, on repeated tests, I would guess that any of the methods could come in at any position.  Your and datanull's methods are definitely easier to type and I'd gladly award both of you correct answers if I could, but it wasn't my post.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1775 views
  • 5 likes
  • 5 in conversation