BookmarkSubscribeRSS Feed
menhtp
Calcite | Level 5

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.

13 REPLIES 13
PGStats
Opal | Level 21

Please show the code you tried so far. - PG

PG
menhtp
Calcite | Level 5

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

PGStats
Opal | Level 21

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

PG
menhtp
Calcite | Level 5

So no code in sas that can arrange the tables side by side before export?

PGStats
Opal | Level 21

Export to what? Where?

PG
menhtp
Calcite | Level 5

To CSV

PGStats
Opal | Level 21

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

PG
menhtp
Calcite | Level 5

Is it the OUT= dataset(s) you are after? - PG

that's correct sorry not CSV.



menhtp
Calcite | Level 5

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.

PGStats
Opal | Level 21

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

PG
menhtp
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ

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

Ksharp
Super User

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 .

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 2211 views
  • 3 likes
  • 4 in conversation