Hi.
I have the following variables from a subset data:
Obs A1 A2 A3 B1 B2 B3 C1 C2 C3 ....
1
2
3
4
5
How do I merge all A variables to become one column, similarly for B and C?
Some rows maybe totally empty e.g. (Row 3) . How do I exclude such rows in the code?
The output will look like:
Obs A B C ....
1
2
4
5
1
2
4
5
1
2
4
5
Thank you.
Something like this?
data have;
input A1 A2 A3 B1 B2 B3 C1 C2 C3;
datalines;
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 6
5 7 2 0 8 6 5 8 6
4 6 3 9 7 1 6 9 7
4 8 3 5 8 3 1 6 9
;
data want(keep= A B C);
set have;
array As{*} A:;
array Bs{*} B:;
array Cs{*} C:;
do i=1 to dim(As);
A=As[i];B=Bs[i];C=Cs[i];
output;
end;
run;
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.