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.
Use the INFILE statement with option FIRSTOBS=2
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.