BookmarkSubscribeRSS Feed
saikiran_nemani
Obsidian | Level 7

Recently I am facing an Issue with Excel when we Write an ODS Statement .When the Program is completed and when I receive an email and open that excel file I am getting the below Error:

 

the file you are trying to open is in a different format than specified by the file extension .

 

 

20 REPLIES 20
Tom
Super User Tom
Super User

That means that the extension on the file does not match the content. Your system is warning you that someone might be trying to fool you into opening a file that might be dangerous.

 

If you use ODS EXCEL then the extension on the file should be XLSX as that is the format it generates.

If you use ODS TAGSETS=excelxp  then the extension on the file should be XML as that is the format it generates.

If you use ODS CSV then extension is CSV.

If you use ODS HTML then extension is HTML.

etc.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

show your exporting code would help.

 

are you exporting to xls using excelcs?

 

saikiran_nemani
Obsidian | Level 7
Hi All,

Thanks for your quick response.

I am using EXCEL 2010 but the code is saying that .xls

For 2007 above versions we need to keep .xlxs extension ?
Reeza
Super User
It depends on the code you used to export, not the version of Excel.
Cynthia_sas
SAS Super FREQ
Hi:
@Reeza is correct. The file extension you use will depend on the ODS statements. For example, if you are using TAGSETS.EXCELXP, the correct file extension is .XML, NOT .XLS - otherwise, Excel will complain with exactly the message you describe.

My recommendation is that you should change the code and use the file extensions shown in Reeza's post. Or else, change the registry, as described in this Tech Support note: http://support.sas.com/kb/31/956.html .

Hope this helps,
Cynthia
ballardw
Super User

@saikiran_nemani wrote:

Recently I am facing an Issue with Excel when we Write an ODS Statement .When the Program is completed and when I receive an email and open that excel file I am getting the below Error:

 

the file you are trying to open is in a different format than specified by the file extension .

 

 


 

ODS statement code please.

saikiran_nemani
Obsidian | Level 7
ODS listing;

ODS HTML FILE='/sas/sai/repeat_faults2.xls;

ODS HTML CLose;
Kurt_Bremser
Super User

You try to lie to Excel, disguising a HTML file as an Excel file, and Excel rightfully complains about this.

Use the proper extension:

ODS HTML FILE='/sas/sai/repeat_faults2.html';

and open the file from within Excel (do not double-click the file in Explorer).

saikiran_nemani
Obsidian | Level 7
@Kurt Bremser :

I need to export the file in excel.

Please give any suggestions.
Reeza
Super User
What version of SAS are you using?
saikiran_nemani
Obsidian | Level 7
SAS 9.3 and excel oss is not working
Reeza
Super User
No, ODS EXCEL isn't available in 9.3.
ODS TAGSETS.EXCELXP is as close as you can get and you need to use the XML extension. It does most of what ODS EXCEL does, just doesn't give a native Excel file. You could convert it after the fact, there's a vbs macro that does that on sas support website.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

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
  • 20 replies
  • 3425 views
  • 0 likes
  • 7 in conversation