BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chuakp
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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

View solution in original post

2 REPLIES 2
dav_amol
Calcite | Level 5

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).

Linlin
Lapis Lazuli | Level 10

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

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
  • 2 replies
  • 26502 views
  • 6 likes
  • 3 in conversation