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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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