DATA Step, Macro, Functions and more

Conversion of output file

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Conversion of output file

How can I convert output (.lst) file to xlsx format?

Thanks.


Accepted Solutions
Solution
‎04-13-2016 10:48 AM
Super User
Super User
Posts: 7,942

Re: Conversion of output file

Whilst I totally agree with @Reeza and @KurtBremser, create your output from SAS using the tools to create Excel files, you can import text (which is what a .lst file is) into Excel and process it if you really have to.  Open Excel, goto Data->From Text, select your file (as its not .txt you will need to select All Files *.* in the filetypes box).  You will then see the Text Import Wizard, where you can set various options, delimiters, widths etc.  

 

Do note, that .lst files are just raw text, so there would be no formatting, and strcuturally it isn't the best to deal with.  Better to generate a proper report from SAS.

View solution in original post


All Replies
Super User
Posts: 19,789

Re: Conversion of output file

You can't directly. 

 

If you're on SAS 9.4 though you can use ODS EXCEL to create an Excel file. 

 

You add 

 

ods excel file='file path/name.xlsx;

 

your sas code;

 

ods excel close;

 

This will produce an excel file with your results. You can create PDF or RTF/Word files in a similar manner. 

New Contributor
Posts: 2

Re: Conversion of output file

Thanks Reza.

When I run sas code only, it works fine. When I add your suggested lines at the beginning and end, I get error messages. Possibly I need to work on it a bit more.

Super User
Posts: 7,774

Re: Conversion of output file

Also have a look at ODS TAGSETS.EXCELXP. You get XML output that is properly read by Excel and can contain advanced formatting.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎04-13-2016 10:48 AM
Super User
Super User
Posts: 7,942

Re: Conversion of output file

Whilst I totally agree with @Reeza and @KurtBremser, create your output from SAS using the tools to create Excel files, you can import text (which is what a .lst file is) into Excel and process it if you really have to.  Open Excel, goto Data->From Text, select your file (as its not .txt you will need to select All Files *.* in the filetypes box).  You will then see the Text Import Wizard, where you can set various options, delimiters, widths etc.  

 

Do note, that .lst files are just raw text, so there would be no formatting, and strcuturally it isn't the best to deal with.  Better to generate a proper report from SAS.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 216 views
  • 4 likes
  • 4 in conversation