user2548060
user2548060

Reputation: 19

use DATALINES to read in data, with tab delimeter

I am trying to use the tab key as my delimiter to directly put datalines in the program, but an error 'LOST CARD' shows up in the log. Here goes a toy program.

    data demo;
    infile datalines dlm = "09"x;
    input Gender $ Age Height Weight;
    datalines;
    M        45        23        120;
    run;

Upvotes: 1

Views: 8467

Answers (3)

user2198210
user2198210

Reputation: 88

It works also with datalines as already explained here above. I used copy-paste from Excel which uses tabs as separators.

    data test;
        infile datalines DSD delimiter='09'x;
        input nimi $ inva exam $;
        datalines;
    Mary    1   2017K
    Mary    0   2016K
    ;

Upvotes: 0

overwhelmed
overwhelmed

Reputation: 225

From https://www.ciser.cornell.edu/FAQ/SAS/other_delimiters.shtml
Example to read a tab delimited file:

  filename two  'u:\data2.txt';     /* this is your raw data file */ 
  data new2; 
  infile two  DSD delimiter='09'x;      /* use hexidecimal code for tab delimiters */ 
  input var1-var10 ; 
  run;  

Upvotes: 0

Joe
Joe

Reputation: 63424

Your issue is likely that your tabs are being replaced by spaces. Try using something else for a delimiter; tab is not a very good choice for datalines/other text-entered data.

Also, your semicolon after the data ought to be on a line by itself.

Upvotes: 4

Related Questions