Output SAS Graph to Excel

425 Views Asked by At

I'm trying to export the Kaplan-Meier curves and data outputted from a PROC PHREG output.

Here's the snippet of my code that is problematic:

proc lifetest data=Xen plots=survival(pvalue atrisk= 0 to 12 by 2);
title 'Percentage pts with IOP <=14 Complete Success';
time Months*CS14(0);
strata Tx / test=(logrank);

ods output summary = IOP_14_CS;
proc export data=IOP_14_CS outfile='/home/u61695399/Results/3_KM_Curves.xlsx' dbms=xlsx replace;
sheet="IOP_14_CS";run;

When I run this, I get the following error log when ods trace is on (see end of post).

Is there any way to output the table and associated graphics to a corresponding sheet in Excel? I have many of these proc lifetests and proc phreg functions in this sheet, all of which I'd like to save the output to different named Excel sheets.

 Output Added:
 -------------
 Name:       ProductLimitEstimates
 Label:      Product-Limit Estimates
 Template:   Stat.Lifetest.ProductLimitEstimates
 Path:       Lifetest.Stratum1.ProductLimitEstimates
 -------------
 
 Output Added:
 -------------
 Name:       Quartiles
 Label:      Quartiles of the Survival Distribution
 Template:   Stat.Lifetest.Quartiles
 Path:       Lifetest.Stratum1.TimeSummary.Quartiles
 -------------
 
 Output Added:
 -------------
 Name:       Means
 Label:      Mean
 Template:   Stat.Lifetest.Means
 Path:       Lifetest.Stratum1.TimeSummary.Means
 -------------
 
 Output Added:
 -------------
 Name:       ProductLimitEstimates
 Label:      Product-Limit Estimates
 Template:   Stat.Lifetest.ProductLimitEstimates
 Path:       Lifetest.Stratum2.ProductLimitEstimates
 -------------
 
 Output Added:
 -------------
 Name:       Quartiles
 Label:      Quartiles of the Survival Distribution
 Template:   Stat.Lifetest.Quartiles
 Path:       Lifetest.Stratum2.TimeSummary.Quartiles
 -------------
 
 Output Added:
 -------------
 Name:       Means
 Label:      Mean
 Template:   Stat.Lifetest.Means
 Path:       Lifetest.Stratum2.TimeSummary.Means
 -------------
 NOTE: 14460 observations with invalid time, censoring, or strata values were deleted.
 
 Output Added:
 -------------
 Name:       CensoredSummary
 Label:      Censored Summary
 Template:   Stat.Lifetest.CensoredSummary
 Path:       Lifetest.CensoredSummary
 -------------
 
 Output Added:
 -------------
 Name:       HomStats
 Label:      Rank Statistics
 Template:   Stat.Lifetest.HomStats
 Path:       Lifetest.StrataHomogeneity.HomStats
 -------------
 
 Output Added:
 -------------
 Name:       LogrankHomCov
 Label:      Log-Rank Covariance
 Template:   Stat.Lifetest.HomCov
 Path:       Lifetest.StrataHomogeneity.LogrankHomCov
 -------------
 
 Output Added:
 -------------
 Name:       HomTests
 Label:      Homogeneity Tests
 Template:   Stat.Lifetest.HomTests
 Path:       Lifetest.StrataHomogeneity.HomTests
 -------------
 
 Output Added:
 -------------
 Name:       SurvivalPlot
 Label:      Survival Curves
 Template:   Stat.Lifetest.Graphics.ProductLimitSurvival
 Path:       Lifetest.SurvivalPlot
 -------------
 WARNING: Output 'summary' was not created.  Make sure that the output object name, label, or path is spelled correctly.  Also, 
          verify that the appropriate procedure options are used to produce the requested output object.  For example, verify that 
          the NOPRINT option is not used.
 NOTE: PROCEDURE LIFETEST used (Total process time):
       real time           2.07 seconds
       user cpu time       1.60 seconds
       system cpu time     0.08 seconds
       memory              21420.37k
       OS Memory           51388.00k
       Timestamp           2022-09-15 06:48:09 PM
       Step Count                        167  Switch Count  6
       Page Faults                       7
       Page Reclaims                     4595
       Page Swaps                        0
       Voluntary Context Switches        2204
       Involuntary Context Switches      4
       Block Input Operations            33096
       Block Output Operations           3160
       
 
 380        proc export data=Means outfile='/home/u61695399/Results/3_KM_Curves.xlsx' dbms=xlsx replace;
 381        sheet="IOP_14_CS";run;
 
 ERROR: File WORK.MEANS.DATA does not exist.
 NOTE: The SAS System stopped processing this step because of errors.
1

There are 1 best solutions below

0
Reeza On

PROC EXPORT will only export data. Instead you can pipe your output to an Excel file directly using ODS EXCEL.

ods excel file='/home/u61695399/Results/3_KM_Curves.xlsx'; 
proc lifetest data=Xen plots=survival(pvalue atrisk= 0 to 12 by 2);
title 'Percentage pts with IOP <=14 Complete Success';
time Months*CS14(0);
strata Tx / test=(logrank);
run;

ods excel close;