BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Koke
Fluorite | Level 6

Hello guys,

need help by using ARRAY on tranform this

  ID          X1          X2        X3         X4         X5         Y1          Y2          Y3        Y4          Y5 

14547317368
28786754356

 

 

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

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 DATA FROG;
63 INPUT ID X1-X5 Y1-Y5;
64 DATALINES;
 
NOTE: The data set WORK.FROG has 2 observations and 11 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
 
67 ;
 
68 proc
69 print data = frog;
70
71 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
84
 
thank you guys

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 825 views
  • 4 likes
  • 2 in conversation