BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

I have the following results from proc freq tables statement. I will give just a couple lines like:

 

                                                                           Age Grouping

  County                   0-9    10-19   20-29   30-39   40-49   50-59   60-69     70-79    80 and Above    Total

   Baker                      31        14      25        23         12        16        22           13              0                 156

   Benton                    49      141    250        74         46         47       33             7               9                656

 

                                                          . . . . .

 

My question is what is the easiest way I can export the table from the Results Viewer into Excel. 

 

Thank you.

 

wlierman

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Depends on what you're doing. Overall, I usually modify my code, then I have a history of what's been doine.

ods excel file = "path to your excel file" style = meadow;

proc freq code.....


ods excel close;



In EG, you can right click a file and get it to save to Excel as well.

https://blogs.sas.com/content/sgf/2019/04/23/ods-excel-control/

 

Other ways are listed in this post:

https://blogs.sas.com/content/sasdummy/2012/02/11/export-excel-methods/

View solution in original post

4 REPLIES 4
ballardw
Super User

@wlierman wrote:

I have the following results from proc freq tables statement. I will give just a couple lines like:

 

                                                                           Age Grouping

  County                   0-9    10-19   20-29   30-39   40-49   50-59   60-69     70-79    80 and Above    Total

   Baker                      31        14      25        23         12        16        22           13              0                 156

   Benton                    49      141    250        74         46         47       33             7               9                656

 

                                                          . . . . .

 

My question is what is the easiest way I can export the table from the Results Viewer into Excel. 

 

Thank you.

 

wlierman


Use the ODS destination to direct output:

 

ods excel file="c:\folder\my.xlsx";

<proc print goes here>

ods excel close;

If you don't have the license to use ODS excel you can use ods TAGSETS.excelxp and create an XML file that excel should be able to open.

 

Since the results is generally HTML it is not actually Excel content.

wlierman
Lapis Lazuli | Level 10
Both Reeza's and your replies are solutions.-- had to mark one.

Thank you.

wliermaqn
Reeza
Super User

Depends on what you're doing. Overall, I usually modify my code, then I have a history of what's been doine.

ods excel file = "path to your excel file" style = meadow;

proc freq code.....


ods excel close;



In EG, you can right click a file and get it to save to Excel as well.

https://blogs.sas.com/content/sgf/2019/04/23/ods-excel-control/

 

Other ways are listed in this post:

https://blogs.sas.com/content/sasdummy/2012/02/11/export-excel-methods/

wlierman
Lapis Lazuli | Level 10

Thank you Reeza.  Both you and ballardw zeroed in on the method.

 

I appreciate the extra material that you included in your response.

 

Take care.

 

wlierman

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
  • 4 replies
  • 6867 views
  • 1 like
  • 3 in conversation