pmichna
pmichna

Reputation: 4888

SAS and text pointers - not reading all values

data test;
    infile datalines missover;
    input @ "r1" r1
          @ "r2" r2
          @ "r3" r3
          @ "r4" r4;
    datalines;
    r4 34 r2 21 r3    r1 12
    r4 12 r2 19 r3    r1 76
    ;
run;

Why in the test data set I get only values of r1 and the rest is .?

My desired output is:

r1    r2    r3    r4
--------------------
12    21    .     34
76    19    .     12

Upvotes: 3

Views: 54

Answers (1)

pmichna
pmichna

Reputation: 4888

After reading an example in SAS documentation I found the solution:

data test;
    infile datalines missover;
    input @'r1' r1
          @1 @'r2' r2
          @1 @'r3' r3
          @1 @'r4' r4;
    datalines;
    r4 34 r2 21 r3    r1 12
    r4 12 r2 19 r3    r1 76
    ;
run;

It is needed to go back to the beginnig of the line with @1 because without this SAS keeps searching for the given strings from the last pointer location.

Upvotes: 4

Related Questions