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');
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.