data array1;
array mark{*} $ mark1-mark5;
array markplusone{*} $ mark6-mark10;
input mark1-mark5;
do i=1 to dim(mark);
markplusone(i)='a'||mark(i);/*different concatenation*/
end;
drop mark1-mark5;
cards;
a b c d e
;run;
data array1;
array mark{*} $ mark1-mark5;
array markplusone{*} $ mark6-mark10;
input mark1-mark5;
do i=1 to dim(mark);
markplusone(i)=mark(i)||'a'; /*different concatenation*/
end;
drop mark1-mark5;
cards;
a b c d e
;run; /*why this concatenation is not working?*/
The picture attached below is for the second code output.
So mark1 has length 8. So the value is actually the letter 'a' follow by 7 blanks.
Mark6 also has length 8. So when you append the new letter 'a' to mark1, that would make it 9 characters and so the 9th one gets dropped because the length of mark6 is also 8.
How about this:
data array1;
array mark{*} $ mark1-mark5;
array markplusone{*} $ mark6-mark10;
input mark1-mark5;
do i=1 to dim(mark);
markplusone(i)=trim(mark(i))||'a'; /*different concatenation*/
end;
/*drop mark1-mark5;*/
cards;
a b c d e
;run;
or
markplusone(i)=cats(mark(i),'a');
So mark1 has length 8. So the value is actually the letter 'a' follow by 7 blanks.
Mark6 also has length 8. So when you append the new letter 'a' to mark1, that would make it 9 characters and so the 9th one gets dropped because the length of mark6 is also 8.
How about this:
data array1;
array mark{*} $ mark1-mark5;
array markplusone{*} $ mark6-mark10;
input mark1-mark5;
do i=1 to dim(mark);
markplusone(i)=trim(mark(i))||'a'; /*different concatenation*/
end;
/*drop mark1-mark5;*/
cards;
a b c d e
;run;
or
markplusone(i)=cats(mark(i),'a');
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 25. Read more here about why you should contribute and what is in it for you!
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.