- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Example 2 fails because you are trying to replace existing variables. You need to supply new variable names in the NE array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Example 2 fails because you are trying to replace existing variables. You need to supply new variable names in the NE array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content