SAS Studio

Write and run SAS programs in your web browser
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bondtk
Quartz | Level 8

Hi

 

I am writing this code below to export the file to excel, it shows excel file in the folder , when I try to open it, it says file is corrupt.

 

please advise if there is any problem in the code.

 

 

ods excel file='/folders/myfolders/pg2/rawdatapivotnov.xlsx' ;

 

proc summary data=orion.aaamonthlydata nway missing;

class Amount_Financed System_decision lend_level;

 

output out= rawdatapivotnov;

run;

ods excel close;

 

 

I am running SAS Studio via Oracle VM Virtual box manager which I believe is Linux based, my laptop is windows based, is it a conflict of different environment that caused this excel file as corrupt, please advise.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

To be honest, and I haven't checked this, I didn't think proc summary created any ods destination output when run.  Hence nothing is going to the xlsx file.  This line:

output out= rawdatapivotnov;

Says to create a dataset with the output, so maybe after that summary you want to have a proc report step and report out that dataset that was created so some actual data is written out to the xlsx file.

bondtk
Quartz | Level 8

Hi, when I run this code, no error comes, it says 8011 observations read from original data set, work.rawdatapivotnov has 5297 oberservations and 5 variables, excel file is written. But when I open it.  It has error. So not sure what happened,

 

its ts quite easy to export proc summary in SAS EG as it gives the export option, so not sure why SAS studio has no option to export to excel file.

bondtk
Quartz | Level 8

Hi RW9

 

ODS doesn't work for me so I run the proc summary first and then use the proc export after that and it worked.

 

/*code for proc summary */

 

proc summary data=orion.aaamonthlydata nway missing;
class Amount_Financed  System_decision  lend_level;
output out=orion.volumedist;
run;


/* export proc summary to excel file */

 

proc export
  data=orion.volumedist
  dbms=xlsx
  outfile="/folders/myfolders/pg2/rawdatapivotnov.xlsx"
  replace;
run;

bondtk
Quartz | Level 8

Hi Kurt,

 

 

ODS doesn't work for me so I run the proc summary first and then use the proc export after that and it worked.

 

/*code for proc summary */

 

proc summary data=orion.aaamonthlydata nway missing;
class Amount_Financed  System_decision  lend_level;
output out=orion.volumedist;
run;


/* export proc summary to excel file */

 

proc export
  data=orion.volumedist
  dbms=xlsx
  outfile="/folders/myfolders/pg2/rawdatapivotnov.xlsx"
  replace;
run;

bondtk
Quartz | Level 8

Hi Kurt

 

If I replace it with proc means then it creates a proc means report withStd, means , min, max and I can see the excel file, but that's not the output I need,  I need the proc summary report to go as a excel file and then I can run the pivot tables on the excel file. Proc export allowed me to do that, so I am not sure how ods will export the proc summary as an excel file.

 

thanks for your patience. 

Kurt_Bremser
Super User

proc means and proc summary follow the same syntax and have the same functionality, their default settings are different.

Add the print option to the proc summary statement.

bondtk
Quartz | Level 8

Hi Kurt

 

Proc means gives me a table which I cant use for further analysis as I would like to run pivot tables on the data in excel file.

Proc summary gives me the data set which I can use for my purpose. I added the proc print to proc summary.

thanks for your help.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2962 views
  • 0 likes
  • 3 in conversation