I am looking for a way to export only the header of a dataset to Excel. No matter whether I tried, from starting with an empty dataset to using a filter right before the export, SAS doesn't export the tab that contains a header only.
Any suggestions would be highly appreciated.
Thank you!
Do you have to use ODS? This works:
libname out xlsx 'myfile.xlsx';
data out.class;
set sashelp.class (obs=0);
run;
Sounds like you tried to read the XLSX file before SAS had finished creating it. If you open the XLSX with a libname statement you need to clear the libref before it closes the file and saves it.
libname out xlsx 'myfile.xlsx';
data out.class ;
set sashelp.class ;
where age=0;
run;
data out.cars;
set sashelp.cars (obs=5);
run;
libname out clear ;
I still get a $$1 file. I even erased everything in the destination folder, closed Excel, and changed the server from which I run the code. Same exact result. Using a WHERE statement vs. an OBS statement made no difference either.
Thank you.
Click on the vertical dot-dot-dot next the message to see the edit message menu item.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.