BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hi all,

I have a sample code list below.  Is there a way to name the different tabs after getting the Tabulate tables?  Thanks.

ods excel file="Pathway\Dataout_Sites_&tdate..xlsx";

proc tabulate data=Datain1;
  var Total_Cost;
  class class;
  table class*N;
  format class class.;
  where class in (5,6,7,8);
run;

proc tabulate data=Datain2;
  var Lab Radiology Diagnostic_Other;
  class Patient_class;
  table Patient_class * N;
  format Patient_class Patient_class.;
run;

proc tabulate data=Datain3;
  var n;
  class patient_class;
  table patient_class*n*(mean median);
  format patient_clas patient_class.;
run;

ods excel close; 
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
ods excel file="Pathway\Dataout_Sites_&tdate..xlsx" options(sheet_name="DataIn1");

proc tabulate data=Datain1;
  var Total_Cost;
  class class;
  table class*N;
  format class class.;
  where class in (5,6,7,8);
run;

ods excel options(sheet_name="DataIn2");
proc tabulate data=Datain2;
  var Lab Radiology Diagnostic_Other;
  class Patient_class;
  table Patient_class * N;
  format Patient_class Patient_class.;
run;

ods excel options(sheet_name="DataIn3");
proc tabulate data=Datain3;
  var n;
  class patient_class;
  table patient_class*n*(mean median);
  format patient_clas patient_class.;
run;

ods excel close; 


Feel free to use any valid sheet names you want.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
ods excel file="Pathway\Dataout_Sites_&tdate..xlsx" options(sheet_name="DataIn1");

proc tabulate data=Datain1;
  var Total_Cost;
  class class;
  table class*N;
  format class class.;
  where class in (5,6,7,8);
run;

ods excel options(sheet_name="DataIn2");
proc tabulate data=Datain2;
  var Lab Radiology Diagnostic_Other;
  class Patient_class;
  table Patient_class * N;
  format Patient_class Patient_class.;
run;

ods excel options(sheet_name="DataIn3");
proc tabulate data=Datain3;
  var n;
  class patient_class;
  table patient_class*n*(mean median);
  format patient_clas patient_class.;
run;

ods excel close; 


Feel free to use any valid sheet names you want.

--
Paige Miller
ybz12003
Rhodochrosite | Level 12

So, like adding the sheet name in order as below?

ods excel file="Pathway\Dataout_Sites_&tdate..xlsx" options(sheet_name="DataIn1" sheet_name="DataIn2" sheet_name="DataIn3");
PaigeMiller
Diamond | Level 26

That's not the code I provided. The code I provided should work without modification, if your PROC TABULATE blocks are correct.

--
Paige Miller

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