BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hondahawkrider
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 

View solution in original post

5 REPLIES 5
data_null__
Jade | Level 19

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.

hondahawkrider
Fluorite | Level 6

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

data_null__
Jade | Level 19

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.

Reeza
Super User

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. 

Kurt_Bremser
Super User

@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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 6238 views
  • 8 likes
  • 4 in conversation