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?
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;
would compress keeping your numeric values not work?
compress(column,'0123456789','k')
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;
Both of these work thanks for the fast response!
How about CATS?
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 )
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: