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

when we use proc export to export a as table to a certain file do we have to specify the file type?

such as;

 

proc export data=score.score_data (where=(gender='f'))
outfile='/folders/myfolders/Femalelist2.csv'
dbms=csv
replace;

if we remove .csv from the output file, the file can still open in excel or notepad.

 

this is similar to a dlm file,

proc export data=score.score_data
outfile="/folders/myfolders/sd.dat"
dbms=dlm
replace;
delimiter='&';
run;

you can remove .dat and open the output sd file with notepad.

 proc export data=score.score_data
outfile='/folders/myfolders/sd_excel.xls'
dbms=XLSX replace;
sheet='data';
run; 

 

for xlsx, it does not matter if you add .xls. the output is an excel file. 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The extension used on the file is just a convention.  What you NAME the file does not change the content of the file.  But it does help to use the standard extensions that match the content so that others (like your Windows Operating System) have some idea what is in them. 

So if you make a CSV file then use .csv as the extension on the filename.

And you are going to make an XLSX file do NOT mislabel it as an XLS file as those two file formats are different.

 

Excel is normally smart enough to detect the filetype when it opens the file and read it properly even if the extension on the file name does not match the content of the file.  But I would be very wary of using Excel to open a CSV file as Excel will frequently change the data based on what it THINKS the character strings in the CSV file represent. So you can lose significant leading zeros off of identifers and have other strings interpreted as dates.

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

The extension used on the file is just a convention.  What you NAME the file does not change the content of the file.  But it does help to use the standard extensions that match the content so that others (like your Windows Operating System) have some idea what is in them. 

So if you make a CSV file then use .csv as the extension on the filename.

And you are going to make an XLSX file do NOT mislabel it as an XLS file as those two file formats are different.

 

Excel is normally smart enough to detect the filetype when it opens the file and read it properly even if the extension on the file name does not match the content of the file.  But I would be very wary of using Excel to open a CSV file as Excel will frequently change the data based on what it THINKS the character strings in the CSV file represent. So you can lose significant leading zeros off of identifers and have other strings interpreted as dates.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 720 views
  • 1 like
  • 2 in conversation