- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-12-2021 05:09 AM
(4528 views)
I have one csv file path is 'D:\Parc\file_dump.csv' and we have to take 2nd row as column names.
Note: dont delete first row.
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the INFILE statement with option FIRSTOBS=2
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How do you import this CSV file ?
data step or PROC IMPORT ( try option : datarow=3 )
data step or PROC IMPORT ( try option : datarow=3 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Proc import only and datarow option is like data starting record but this
option won't use for column names
option won't use for column names
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Delete the first line ?
filename x temp;
data _null_;
infile 'c:\temp\root.csv' lrecl=32767;
input;
file x ;
if not missing(_infile_) then put _infile_ ;
run;
proc import datafile=x out=x dbms=csv replace;
getnames=yes;
guessingrows=max;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Or rename it after importing ?
proc import datafile='c:\temp\root.csv' out=data dbms=csv replace;
datarows=3;
guessingrows=max;
run;
options obs=2;
proc import datafile='c:\temp\root.csv' out=vname dbms=csv replace;
run;
options obs=max;
proc transpose data=vname out=vname2;
var _all_;
run;
proc sql noprint;
select catt(_name_,'=',col1) into :rename separated by ' ' from vname2;
quit;
proc datasets library=work nolist nodetails;
modify data;
rename &rename. ;
quit;