Need help Im proctabulating two tables A and B from the same data source. When i do, the other table appears at the bottom. I want the two tables to be arranged next to each other like this ( just example)
Tablea Table b
xxxx xxxx
xxxx xxxx
xxxx xxxx
Thanks.
Please show the code you tried so far. - PG
Ive used a code like this
Proc tabulate data = tablea
class item1 item2;
var colour;
table item1 all, item2 All;
run;
Proc tabulate data = tableb
class desp1 desp2;
var colour;
table desp1 all, desp2 All;
run;
I just want output table to display side by side.
Thanks
I get something half decent with option columns=2 :
option orientation=portrait nodate nonumber;
title;
ods rtf file="&sasforum.\Reports\tabulate 2 col.rtf" columns=2 style=journal;
proc tabulate data=sashelp.class format=6.1;
class sex age;
var height;
table sex, height*age*mean="";
run;
proc tabulate data=sashelp.class format=6.1;
class sex age;
var weight;
table sex, weight*age*mean="";
run;
ods rtf close;
PG
So no code in sas that can arrange the tables side by side before export?
Export to what? Where?
To CSV
As far as I know, CSV format supports data tables but not report tables (with multi-level column and row headings). Is it the OUT= dataset(s) you are after? - PG
Is it the OUT= dataset(s) you are after? - PG
that's correct sorry not CSV.
Just looking to the out = than could arrange the tables next to each other. Not sure whre I will position your code on my code.
Could you explain the bit below?
ods rtf file="&sasforum.\Reports\tabulate 2 col.rtf" columns=2 style=journal;
Thanks.
The ODS RTF statement directs procedure printed output to a .rtf file (compatible with Word). FILE= names the file that will be created, STYLE=journal chooses a table layout style named journal (default is HTMLBLUE) and COLUMNS=2 requests two printed columns. - PG
Hi PG
Thanks your method works
When I do the export, results show on a microsoft word document. is it possible to export on EXCEL in the same format so tables arranged to next to each other?
Thanks.
Hi, when you do a "true" EXPORT, you are sending SAS data format to other data format (for example SAS data format exported to SPSS data format, or SAS data format exported to DBF data format or SAS data format to Excel data format) You do a true data-to-data export with PROC EXPORT or the SAS Libname engine. In that scenario, then your two separate tables (data tables from OUT=) would NOT be placed side by side.
However, as shown by PGStats, when you move to a REPORT format, for some (but not all) destinations, you can get "side by side" REPORT tables (not data tables). As far as ODS CSV, there is no support of the COLUMNS=2 option. That option is only for RTF/PDF, which are paged destinations and have the controls to do multi-column REPORT documents.
When you use ODS, you have several methods to create ASCII text REPORT files -- either CSV, HTML or XML -- that Excel knows how to open and render. Unless you post process the CSV output (such as suggested by Xia), ODS CSV does not support the COLUMN option. ODS HTML does not support the COLUMN option. There is an ODS Destination called ODS HTMLPANEL, that will produce columnar output -- but the output is meant to be opened in a browser. I believe that the other destinations -- like ODS TAGSETS.EXCELXP and the experimental ODS EXCEL will put each TABULATE output on a separate worksheet, not side-by-side.
So, in the end, it remains to be seen whether you want a SAS data-to-Excel data output or a SAS output report-to-Excel report document output. You might be able to use the PROC EXPORT or Libname engine methods to write named ranges side-by-side -- but that generally means you have to create the named ranges first.
cynthia
You can use Notepad++ to get this once you output these two table into a CSV file.
Open it by Notepad++ and Use ALT+mouse selection to copy the second table at the next of the first table .
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.