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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.