I have a scipt - that runs great, it does a proc export to a .csv file file. It's dynamic (see https://communities.sas.com/t5/Base-SAS-Programming/SAS-Automation-Export/td-p/315194) for the full script... My issue is that while it run great, the CSV ouput that is created also creates the data with a tab name that is the same as the outout file name.. So if my output is core_fed_ack_gen_data_12_06_182127.csv then the tab name inside the csv is core_fed_ack_gen_data_12_06_182 (it cuts off a few chars - but no biggie).. What I would like to do is find a way to genericize just the tab name to core_fed_ack_gen_data or even just sheet 1 or whatever...
Thanks in advance
proc export
data=ALL
outfile="C:\Users\d7dmb\Documents\core_fed_ack_gen_data_12_06_182127.csv"
dbms=csv
replace
A CSV file is a comma separated text file with no concepts of sheets or tabs. Excel is the default viewer for CSV files, but it should be a text editor really. When Excel opens a CSV file it defaults with creating a Sheet name that is the same as the file name. This is fully Excel behaviour that would have ot be changed via Excel if at all possible.
So, no, you can't do what you want via SAS.
The issue you describe has nothing to do with the CSV file created by PROC EXPORT. Your issue is with EXCEL used to open and view the CSV.
Im just trying to find out if in the dbms section .. if there is a way for SAS to NOT have it so the tab name is the same as the file name, but rather something generic.. I can alter my SAS script so it's using a more generic named file, but I like having the date in the file name if possible
CSV is flat file there is no SHEET TAB or TAB name. That TAB and name is being produced by EXCEL when you use it to open the file.
A CSV file is a comma separated text file with no concepts of sheets or tabs. Excel is the default viewer for CSV files, but it should be a text editor really. When Excel opens a CSV file it defaults with creating a Sheet name that is the same as the file name. This is fully Excel behaviour that would have ot be changed via Excel if at all possible.
So, no, you can't do what you want via SAS.
@hondahawkrider wrote:
Im just trying to find out if in the dbms section .. if there is a way for SAS to NOT have it so the tab name is the same as the file name, but rather something generic.. I can alter my SAS script so it's using a more generic named file, but I like having the date in the file name if possible
Think about it: where in the CSV file would you find the tab name? Answer: nowhere.
This is a pure Excel issue.
If you want to find a workaround in SAS, look at ODS TAGSETS.EXCELXP (to write a report to a named sheet), or LIBNAME EXCEL (to write a pseudo-dataset/sheet into an existing Excel workbook).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.