The SAS Output Delivery System and reporting techniques

Combining tables horizontally ,vertically using Proc SQL

Reply
N/A
Posts: 0

Combining tables horizontally ,vertically using Proc SQL

Hi

How can we combine two data sets horizontally, vertically using Proc sql.

Please suggest in this regard.

regards
rupa
New Contributor
Posts: 2

Re: Combining tables horizontally ,vertically using Proc SQL

Posted in reply to deleted_user
Are you trying to create a pivot table as in Excel? If so, use SQL to summarise your data then you would need to use Proc Transpose to create the pivot.


proc sql;
create table summary_data as
select count(outcome) as YTD_count, outcome, issue
from raw_data
group by outcome, issue
order by issue, outcome;
quit;

/*Turn the summary into a pivot table summary */

proc transpose data= summary_data out= pivot_data prefix=YTD_;
by issue ;
id outcome;
var YTD_count;
run;
Super Contributor
Posts: 291

Re: Combining tables horizontally ,vertically using Proc SQL

Posted in reply to deleted_user
Horizontally:

proc sql;
create table horizontal as
select a.*,b.*
from one a, two b
where a.key=b.key

Vertically;

proc sql;
create table vertical as
select *
from one
outer union corr
select *
from two;
Ask a Question
Discussion stats
  • 2 replies
  • 1162 views
  • 0 likes
  • 3 in conversation