Hello guys,
need help by using ARRAY on tranform this
ID X1 X2 X3 X4 X5 Y1 Y2 Y3 Y4 Y5
1 | 4 | 5 | 4 | 7 | 3 | 1 | 7 | 3 | 6 | 8 |
2 | 8 | 7 | 8 | 6 | 7 | 5 | 4 | 3 | 5 | 6 |
into this form.
ID Time X Y
01 1 4 5
01 2 5 7
01 3 4 3
01 4 7 6
here is my code
DATA FROG;
INPUT ID X1-X5 Y1-Y5;
DATALINES;
01 4 5 4 7 3 1 7 3 6 8
02 8 7 8 6 7 5 4 3 5 6
;
proc
print data = frog;
and here is my log
You probably want to use the ARRAY statement to help you deal with an array problem.
Looks like you have an X and a Y array.
data have;
input id x1-x5 y1-y5 ;
cards;
1 4 5 4 7 3 1 7 3 6 8
2 8 7 8 6 7 5 4 3 5 6
;
data want ;
set have ;
array _x x1-x5 ;
array _y y1-y5 ;
do time=1 to dim(_x);
x=_x(time);
y=_y(time);
output;
end;
drop x1-x5 y1-y5 ;
run;
proc print;
run;
You probably want to use the ARRAY statement to help you deal with an array problem.
Looks like you have an X and a Y array.
data have;
input id x1-x5 y1-y5 ;
cards;
1 4 5 4 7 3 1 7 3 6 8
2 8 7 8 6 7 5 4 3 5 6
;
data want ;
set have ;
array _x x1-x5 ;
array _y y1-y5 ;
do time=1 to dim(_x);
x=_x(time);
y=_y(time);
output;
end;
drop x1-x5 y1-y5 ;
run;
proc print;
run;
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.