How do I input data that is exactly as it is below in sas? I tried the command below but it didn't work. I want each group to have seven elements in a row.
data have;
input group $ ddd @@;
datalines;
A: 29 32 26 15 34 15 23
B: 11 30 34 13 27 24 21
C: 22 12 20 7 3 27 4
D: 16 21 13 6 0 9 25
E: 6 2 10 -3 8 1 -4
;
run;
do you mean this?
data have;
input group : $1. @;
do i=1 to 7;
input ddd @;
output;
end;
drop i;
datalines;
A: 29 32 26 15 34 15 23
B: 11 30 34 13 27 24 21
C: 22 12 20 7 3 27 4
D: 16 21 13 6 0 9 25
E: 6 2 10 -3 8 1 -4
;
run;
or this ?
data have;
input group :$1. ddd1-ddd7 ;
datalines;
A: 29 32 26 15 34 15 23
B: 11 30 34 13 27 24 21
C: 22 12 20 7 3 27 4
D: 16 21 13 6 0 9 25
E: 6 2 10 -3 8 1 -4
;
run;
I am still not clear with what you want as output?
wondering if you want something fancy
data have;
input group :$1.@;
array ddd(7);
input ddd{*} ;
datalines;
A: 29 32 26 15 34 15 23
B: 11 30 34 13 27 24 21
C: 22 12 20 7 3 27 4
D: 16 21 13 6 0 9 25
E: 6 2 10 -3 8 1 -4
;
run;
Hello,
Do you mean something like this ?
data have;
infile datalines dlm=":" dsd;
length group $1. ddd $ 50.;
input group ddd;
datalines;
A: 29 32 26 15 34 15 23
B: 11 30 34 13 27 24 21
C: 22 12 20 7 3 27 4
D: 16 21 13 6 0 9 25
E: 6 2 10 -3 8 1 -4
;
run;
If so, you are not doing the future you a favor by using a unique variable to store several values
as it makes data manipulation more difficult.
data have;
infile cards truncover;
input group $ ddd @;
do while(not missing(ddd));
output;
input ddd @;
end;
datalines;
A: 29 32 26 15 34 15 23
B: 11 30 34 13 27 24 21
C: 22 12 20 7 3 27 4
D: 16 21 13 6 0 9 25
E: 6 2 10 -3 8 1 -4
;
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.