How to read values of data file row by row in SAS?

sas

#1

Hi,

I have below raw file, now I want to read it into a new data set as (See below).

Raw Data set

 4       56     65
37       94
67       78     98

Output Data Set

Var1 Var2
 Cat1 4
 Cat1 56
 Cat1 65
 Cat2 37
 Cat2 94
 Cat3 67
 Cat3 78
 Cat3 98

Please help me to perform this.

Regards,
Steve


#2

Hi,

I have used looping to read each variable to each row and also used MISSOVER option with infile statement to prevents an INPUT statement from reading a new input data record if it does not find values in the current input line for all the variables in the statement.

data Test;

    infile datalines missover;
    
	Var1 = Cats('Cat',Put(_n_,3.));
    
	do until (Var2 eq .);
        input Var2 @;
        if Var2 ne . then output;
        else return;
    end;

datalines;
4 56 65
37 94
67 78 98
;
run;

Regards,
Imran