Search code examples
oraclesasproc-sqldatastep

Read in the following table format: no tablehead, [date] colum1=xy colum2=abs colum4=iy


i have a File with the data in the following format:

no tablehead

[date] colum1=xy colum2=abc colum4=xyz

[date] colum1=zz colum3=234 colum4=abc

The problem is, that not every dataset has all of the variables and they´re not seperated by like 2 tabs in that case. Therefore i need to read the file somehow with the columname in front of every datapoint. Im using a oracle database, but also can use SAS.

Thanks in advance


Solution

  • Just use named input mode.

    data want;
      length date $10 column1-column4 $20;
      input date (column1-column4) (=);
    cards;
    [date] column1=xy column2=abc column4=xyz
    [date] column1=zz column3=234 column4=abc
    ;
    

    Results:

    Obs     date     column1    column2    column3    column4
    
     1     [date]      xy         abc                   xyz
     2     [date]      zz                    234        abc