Hi everyone i am trying to import a sas table with proc import statement as headers are in record2 i am using the following code
proc import datafile="WORK.FINAL_1"
out= datatest
dbms=csv(what should be this)
replace;
datarow=2;
Thanks
Assuming you actually have a CSV file (which is form of a delimited text file) but that the problem is that your file has an extra line before the header row. (Note: The header row is one with text strings instead of variable values. These strings are usually used as the names for the variables.)
Let's make an example "bad" csv file by first dumping SASHELP.CLASS to a CSV file and then copying the good CSV file to a new file with an extra row at the top.
If you have such a "bad" CSV file then you cannot use PROC IMPORT to read it directly because PROC IMPORT will always use the FIRST line as the source for guessing how to name the variables, no matter where you tell it to start reading the datalines.
Here are some ways to deal with such a file.
The easiest is to skip the PROC IMPORT and just write your own data step to read the file:
Or you can read from the third row while telling PROC IMPORT not to try to get names from the file. And then rename the variables later. You can even use PROC IMPORT to read the second line to get strings to use as the names.
Or you could make a copy of the CSV file without the extra lines and then you could use PROC IMPORT and it will be able to guess how to name the variables based on the header row.
Or you could use a tool that can guess how to read the file and take the names from somewhere other than the first line. Like %csv2ds().