I do not understand what you are asking since the code you showed does import an XLSX sheet that does not have a header row.
Example:
filename xlsx temp;
proc export dbms=xlsx file=xlsx data=sashelp.class;
putnames=no;
run;
proc import dbms=xlsx file=xlsx out=want replace;
getnames=no;
run;
If you know the names you want to use include them in the output dataset name using the RENAME= dataset option.
proc import dbms=xlsx file=xlsx out=class(rename=(a=name b=sex c=age d=height e=weight)) replace;
getnames=no;
run;
@GreyBlack wrote:
Perhaps I should rephrase; I'm hoping to add headers after performing the
import, but I'm not clear on how to do that.
That makes even less sense. Once the file is imported it is a dataset. Datasets do not have headers. The variables in a dataset have names. If you know the names you want to use for the variables you can include that in the code using the RENAME= dataset option.
proc import dbms=xlsx file=xlsx out=class(rename=(a=name b=sex c=age d=height e=weight)) replace;
getnames=no;
run;
The usual remedy: save to a .csv file and read that with a DATA step, where you set all names, types and attributes without relying on the guesses of PROC IMPORT.
@GreyBlack wrote:
Perhaps I should rephrase; I'm hoping to add headers after performing the
import, but I'm not clear on how to do that.
Your variable names will be A, B, C,...
If you need to rename them then use either a rename statement within a SAS datastep or if you don't need to process the data then use Proc Datasets.
Below some sample code using Proc Datasets.
data work.imported_from_excel;
a=1;
b='a';
c=99;
run;
proc datasets lib=work nolist;
modify imported_from_excel;
rename
a=myvar
b=some_other_name
c=new_name
;
run;
quit;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.