0
votes

I have a text file (1.txt) as follows:

age height
20  180
35  165
44  175

I can use

data dat1;
  infile '1.txt' firstobs=2;
  input age height;
run;

to read the file into SAS. My question is, is there an automatic way of reading the header (variable names), that is, age and height into SAS without using 'input'? If I have many variables, I don't want to specify them one by one.

Thanks.

1

1 Answers

1
votes

You can use PROC IMPORT with the GETNAMES and DATAROW options appropriately set...

See the SAS Documentation : http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000312413.htm

/* delimiter = '09'x is tab-delimited */
proc import datafile='1.txt' out=dat1 getnames=yes datarow=2 dbms=dlm delimiter='09'x;
run ;