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-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!

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.

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
  • 6 replies
  • 1372 views
  • 5 likes
  • 5 in conversation