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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.