infile .csv file in sas with header

useR picture useR · Mar 27, 2015 · Viewed 15.8k times · Source

I have a csv file which named dataset1.csv and it contains header with 3 variables att1 (character), att2 and att3 (numeric data).

I tried following code

filename test 'C:\Users\1502911\Desktop\Practice\SAS\Dataset';

data dataset1;
    infile test(dataset1.csv) dsd delimiter=',';
    input att1 $ att2 att3;
run;

enter image description here

My desired output is to ignore first row

Answer

NEOmen picture NEOmen · Mar 27, 2015

Use firstobs option in infile statement, which would make sure you read the data from second row

http://support.sas.com/documentation/cdl/en/lestmtsref/67407/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm

data dataset1;
    infile test(dataset1.csv) dsd delimiter=',' firstobs=2;
    input att1 $ att2 att3;
run;