Each observation under Y has four values. I tried the following:
data one;
input X Y;
datalines;
2.5 7.5 9.5 8.0 8.5
5.0 11.0 12.0 9.0 10.0
7.5 11.0 16.0 12.5 14.0
10.0 16.5 14.5 21.5 19.0
;
run;
How do I enter the following data below in SAS using datalines?
X Y
2.5 7.5 9.5 8.0 8.5
5.0 11.0 12.0 9.0 10.0
7.5 11.0 16.0 12.5 14.0
10.0 16.5 14.5 21.5 19.0
This does not seem like a smart way to store data. You can only define Y like this as a character variable like this
data one;
input X Y $20.;
infile datalines dlm=',';
datalines;
2.5,7.5 9.5 8.0 8.5
5.0,11.0 12.0 9.0 10.0
7.5,11.0 16.0 12.5 14.0
10.0,16.5 14.5 21.5 19.0
;
run;
A more proper way of defining the data would be as four numeric variable Y1-Y4 like this
data one;
input X Y1-Y4;
datalines;
2.5 7.5 9.5 8.0 8.5
5.0 11.0 12.0 9.0 10.0
7.5 11.0 16.0 12.5 14.0
10.0 16.5 14.5 21.5 19.0
;
run;
This does not seem like a smart way to store data. You can only define Y like this as a character variable like this
data one;
input X Y $20.;
infile datalines dlm=',';
datalines;
2.5,7.5 9.5 8.0 8.5
5.0,11.0 12.0 9.0 10.0
7.5,11.0 16.0 12.5 14.0
10.0,16.5 14.5 21.5 19.0
;
run;
A more proper way of defining the data would be as four numeric variable Y1-Y4 like this
data one;
input X Y1-Y4;
datalines;
2.5 7.5 9.5 8.0 8.5
5.0 11.0 12.0 9.0 10.0
7.5 11.0 16.0 12.5 14.0
10.0 16.5 14.5 21.5 19.0
;
run;
Or perhaps:
data one; input X @; do i= 1 to 4; input Y @; output; end; drop i; datalines; 2.5 7.5 9.5 8.0 8.5 5.0 11.0 12.0 9.0 10.0 7.5 11.0 16.0 12.5 14.0 10.0 16.5 14.5 21.5 19.0 ; run;
Which creates 4 pairs of x, y values with the same X.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: