BookmarkSubscribeRSS Feed
JUMMY
Obsidian | Level 7

 

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;
8 REPLIES 8
novinosrin
Tourmaline | Level 20

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;
JUMMY
Obsidian | Level 7
@novinosrin, is there a way it can be written out in horizontal form?
novinosrin
Tourmaline | Level 20

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;
JUMMY
Obsidian | Level 7
@novinosrin, how can I get rid of ddd1-ddd7? I prefer this way though?
novinosrin
Tourmaline | Level 20

I am still not clear with what you want as output?

novinosrin
Tourmaline | Level 20

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;
gamotte
Rhodochrosite | Level 12

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.

Ksharp
Super User
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;
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2453 views
  • 0 likes
  • 4 in conversation