Hello,
Suppose I want to concatenate a letter at the end of a numeric variable. I run the follow code and it works.
Example 1:
data example1;
set example1 (keep=p18);
p18 =round (p18,.1);
z=catx('',p18,.E);
run;
It returns, for example, a value character value z =12.2E.
When I apply the same CATX function within an array, it does not work. The code used in show below.
Example 2:
data example2;
set example2 (keep= mean mean_SE mean_CV
p1 p1_SE p1_CV
p18 p18_SE p18_CV);
array E {3} mean p1 p18;
array NE {3} $ mean p1 p18;
array SE {3} mean_SE p1_SE p18_SE;
array CV {3} mean_CV p1_CV p18_CV;
do i = 1 to 3;
if 16.6 < CV[i] < 33.3 then do;
NE[i] = catx('',E[i],.E);
SE[i] = .;
end;
end;
drop i;
run;
Can anyone please advice? It would be great if you can also suggest me how to round all the values for a numeric array.
Thanks a lot,
AG.
Why are you using CATX() if you don't actually have any string that you want inserted between the values? Use CATS() instead.
You need to make up your mind whether the variables MEAN, P1 and P18 are numbers or character strings. They cannot be both at the same time.
Why not make NEW variables for the new values?
array E mean p1 p18;
array NE $13 mean_e p1_e p18_e;
Note you don't need to tell the ARRAY statement how many variables the array references when you have listed all of the variables explicitly in the array statement already.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.