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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.