The SAS Output Delivery System and reporting techniques

Proc tabulate - naming the table...

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Proc tabulate - naming the table...

Hi there,

I'm new to SAS and need to create many tables which are a cross tabulated format.

These outputs will then be exported and referenced by excel which will generate charts and conditional formats.

The trouble is that I don't seem to be able to name the output table with the proc tabulate - they all get called summary table1 etc.  When there will be so many tables, how can I then know which to export and save as what...

Suggestions?

I've tried multiple google searches and not returned much, as well as looked at these forums but not found this specific answer.  The questions to date are about naming the variables - not the table.

If there is documentation that directs on this, please could you tell me the name of the manuals to look at.

Cheers,

JJ


Accepted Solutions
Solution
‎08-17-2015 07:32 PM
SAS Super FREQ
Posts: 8,720

Re: Proc tabulate - naming the table...


Hi:

  It depends on your code and your destination how you will name the TABULATE output tables. Are you using OUT= to name the output data or are you using ODS? For me, this works to make one output file named KOALA.HTML and the other output file is named WOMBAT.HTML. Then the OUT= option in each step makes an output dataset from the TABULATE procedure.

Cynthia

     

ods html file='c:\temp\koala.html';

proc tabulate data=sashelp.shoes out=work.table_koala;

where product contains 'Casual';

class region;

var sales inventory;

  table region all,

        sales*(sum mean) inventory*sum;

run;

ods html close;

ods html file='c:\temp\wombat.html';

proc tabulate data=sashelp.shoes out=work.table_wombat;

where product contains 'Casual';

class region;

var sales returns;

  table region all,

        sales*(sum mean) returns*sum;

run;

ods html close;

View solution in original post


All Replies
Solution
‎08-17-2015 07:32 PM
SAS Super FREQ
Posts: 8,720

Re: Proc tabulate - naming the table...


Hi:

  It depends on your code and your destination how you will name the TABULATE output tables. Are you using OUT= to name the output data or are you using ODS? For me, this works to make one output file named KOALA.HTML and the other output file is named WOMBAT.HTML. Then the OUT= option in each step makes an output dataset from the TABULATE procedure.

Cynthia

     

ods html file='c:\temp\koala.html';

proc tabulate data=sashelp.shoes out=work.table_koala;

where product contains 'Casual';

class region;

var sales inventory;

  table region all,

        sales*(sum mean) inventory*sum;

run;

ods html close;

ods html file='c:\temp\wombat.html';

proc tabulate data=sashelp.shoes out=work.table_wombat;

where product contains 'Casual';

class region;

var sales returns;

  table region all,

        sales*(sum mean) returns*sum;

run;

ods html close;

Occasional Contributor
Posts: 8

Re: Proc tabulate - naming the table...

Hi there,

Thank you this worked perfectly.

For 10 extra points ;-), using your example above, could you tell me if it's possible to set sales to be "cupcakes" before hand, and then have "cupcakes" in the code?

Reason for asking is that I have multiple iterations of this code, generating numerous tables to be analysed, and to set that variable in advance and have to only change it in one place would reduce risk of errors creeping in.

Grand Advisor
Posts: 10,218

Re: Proc tabulate - naming the table...

One solution you'd be looking for is a simple macro variable. Note the changes in the code to use " instead of ' to allow resolution of the macro variable, the reference the variable has & and first . in &topic..html says that what follows is concatenated with the variable but since you want a dot as part of the file name you need a second one.

%let topic=wombat;

ods html file="c:\temp\&topic..html";

proc tabulate data=sashelp.shoes out=work.table_&topic;

where product contains 'Casual';

class region;

var sales returns;

  table region all,

        sales*(sum mean) returns*sum;

run;

ods html close;

Next step would be actual macro programming, parameters and fun.

SAS Super FREQ
Posts: 8,720

Re: Proc tabulate - naming the table...

And, for the extra 10 points, here's a paper I wrote about Macro Basics for New SAS Users: https://support.sas.com/resources/papers/proceedings13/120-2013.pdf   It may help you get started.

cynthia

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 497 views
  • 0 likes
  • 3 in conversation