I'm running seven regressions on multiple outcomes using the same model specification. I want to create a Word file that contains all of the coefficients and p values in a single table, like one that you might present in a journal article.
Let's say I'm running a regression using PROC SURVEYREG (note that the variable Probt is the p value):
proc surveyreg data = dataset;
weight perwt;
strata varstr;
cluster varpsu;
class sex region;
model spending = age sex region /solution;
ods output ParameterEstimate = coefficients (keep = Parameter Estimate Probt);
run;
The dataset coefficients might look something like this:
Parameter Estimate Probt
AGE 0.396 0.002
SEX 0.002 0.953
REGION 0.125 0.593
Let's say I run a second regression using identical code, except that I use a different outcome variable (say, HEALTH). I then save the ParameterEstimate table to a dataset coefficients2.
Parameter Estimate Probt
AGE 0.132 0.321
SEX 0.352 0.835
REGION 0.653 0.001
What I want to make is a single table that looks like this:
SPENDING HEALTH
Parameter Estimate Probt Estimate Probt
AGE 0.396 0.002 0.132 0.321
SEX 0.002 0.953 0.352 0.835
REGION 0.125 0.593 0.653 0.001
It's easy to concatenate SAS datasets vertically (by stacking them on top of each other) but I want to figure out how to do this "horizontally." I don't know PROC SQL and don't know if there's a good way to do this without using this PROC.
Thanks.
how about:
data have1;
input Parameter $ : s_Estimate : s_Probt;
cards;
AGE 0.396 0.002
SEX 0.002 0.953
REGION 0.125 0.593
;
run;
data have2;
input Parameter $ : h_Estimate : h_Probt;
cards;
AGE 0.132 0.321
SEX 0.352 0.835
REGION 0.653 0.001
run;
data want;
merge have1 have2;
run;
proc print;run;
Obs Parameter s_Estimate s_Probt h_Estimate h_Probt
1 AGE 0.396 0.002 0.132 0.321
2 SEX 0.002 0.953 0.352 0.835
3 REGION 0.125 0.593 0.653 0.001
Linlin
Try This ,
PROC SQL;
create table results as
select a.parameter ,
a.Estimate as Spending_estimate ,
a.probt as Spending_probt ,
b.estimate as Health__Estimate ,
b.probt as Health_probt
from Table1 as a inner join table2 as b
on a.parameter = b.parameter;
quit;
Here if you want to include non-common records also then use Full outer join with COALESCE(a.parameter,b.parameter).
how about:
data have1;
input Parameter $ : s_Estimate : s_Probt;
cards;
AGE 0.396 0.002
SEX 0.002 0.953
REGION 0.125 0.593
;
run;
data have2;
input Parameter $ : h_Estimate : h_Probt;
cards;
AGE 0.132 0.321
SEX 0.352 0.835
REGION 0.653 0.001
run;
data want;
merge have1 have2;
run;
proc print;run;
Obs Parameter s_Estimate s_Probt h_Estimate h_Probt
1 AGE 0.396 0.002 0.132 0.321
2 SEX 0.002 0.953 0.352 0.835
3 REGION 0.125 0.593 0.653 0.001
Linlin
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.