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');
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: