DATA Step, Macro, Functions and more

how can I make two lines of obs rather than one line?

Reply
Frequent Contributor
Posts: 133

how can I make two lines of obs rather than one line?

data crv4;

input

i1r1 i1r2 i1r3 i1r4 i1r5 i1r6 i1r7 i1r8 i1r9 i1r10 i1r11 i1r12 i1r13

    /                                                                   

i2r1 i2r2 i2r3 i2r4 i2r5 i2r6 i2r7 i2r8 i2r9 i2r10 i2r11 i2r12 i2r13;

cards;

4 4.5 5 5.5 6 6.5 7 7.5

8 8.5 9 9.5 10

0.4835 . 0.7335

. . . 1.184 . . . . . 1.64

;

I want to i2r1 and rest of it become 2nd obs, so i will have two lines of obs.

SAS keeps making only 1 line.

how can I correct it?

SAS Employee
Posts: 104

how can I make two lines of obs rather than one line?

Try reading each line separately with an OUTPUT statement in between.  For example:

data crv4; 
   infile datalines truncover;
   input i1r1 i1r2 i1r3 i1r4 i1r5 i1r6 i1r7 i1r8 i1r9 i1r10 i1r11 i1r12 i1r13;
   output;
   call missing (of i1r1--i1r13);
   input i2r1 i2r2 i2r3 i2r4 i2r5 i2r6 i2r7 i2r8 i2r9 i2r10 i2r11 i2r12 i2r13;
   output;
cards;
4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10
0.4835 . 0.7335 . . . 1.184 . . . . . 1.64
;
run; 
Super User
Posts: 9,676

how can I make two lines of obs rather than one line?

The code below is what you need?

data crv4;
infile cards truncover;
input
i1r1 i1r2 i1r3 i1r4 i1r5 i1r6 i1r7 i1r8 i1r9 i1r10 i1r11 i1r12 i1r13 ;
cards;
4 4.5 5 5.5 6 6.5 7 7.5
8 8.5 9 9.5 10
0.4835 . 0.7335
. . . 1.184 . . . . . 1.64
;
run;

Ksharp

Frequent Contributor
Posts: 133

how can I make two lines of obs rather than one line?

I c, I guess the truncover does the trick, but see following code:

data t;

input

    k1f1    k1f2    k1f3    k1f4    k1f5    k1f6    k1f7    k1f8    k1f9    k1f10

    /                                                                               

    k2f1    k2f2    k2f3    k2f4    k2f5    k2f6    k2f7    k2f8    k2f9    k2f10;

cards;

56.7 58.7 68.3 70.3 61.9 87.6 99.3 65.3 78.3 91.5

88.5 63.9 66.8 77.6 55.9 35.9 54.8 98.6 77.3 68.5

51.6 88.7 79.6 65.9 94.1 91.6 83.6 85.7 66.8 77.9

98.5 79.9 99.9 55.6 68.9 46.8 79.8 88.6 88.8 97.5

;

It does break into two lines too, and didn't use truncover, why is that?

Super User
Posts: 9,676

how can I make two lines of obs rather than one line?

Because you use / operation which will make pointer to point the next line,

If you need two obs then remove it.

input

    k1f1    k1f2    k1f3    k1f4    k1f5    k1f6    k1f7    k1f8    k1f9    k1f10

                                                                           

    k2f1    k2f2    k2f3    k2f4    k2f5    k2f6    k2f7    k2f8    k2f9    k2f10;

Ksharp

Ksharp

Ask a Question
Discussion stats
  • 4 replies
  • 157 views
  • 0 likes
  • 3 in conversation