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

Dear all,

I posted two screenshots; one with regular SAS output from a logistic regression, where I adjusted the standard errors to be reported with parentheses. The other screenshot is an Excel spreadsheet picture of the table orientation that I would like to be able to run directly from SAS. I have not figured out how to have the estimates and the standard errors in one column per variable.

I appreciate your input.

Thank you,

Pieter

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Here is an example based on data step processing

 

data class;
set sashelp.class;
old = age > 13;
run;

proc logistic data=class;
class old sex;
model old = sex | height | weight / noint;
ods output parameterEstimates=pe;
run;

data pe2;
set pe; where variable is not missing;
stdErrStr = put(estimate, 10.4);
output;
call missing(variable, probChiSq);
stdErrStr = cats("(", put(stdErr, pvalue8.4), ")");
output;
run;

options missing=" ";
proc print data=pe2 noobs;
var variable stdErrStr probChiSq;
label stdErrStr = "Estimate";
run;
Variable 	stdErrStr 	ProbChiSq
Sex 	70.9267 	0.7576
  	(229.8318) 	 
Height 	0.0413 	0.7811
  	(0.1487) 	 
Height*Sex 	-0.9285 	0.7983
  	(3.6329) 	 
Weight 	0.4995 	0.3898
  	(0.5809) 	 
Weight*Sex 	-1.1886 	0.6238
  	(2.4237) 	 
Height*Weight 	-0.0083 	0.3214
  	(0.0084) 	 
Height*Weight*Sex 	0.0167 	0.6605
  	(0.0380) 	 

Note this forum interface does not do justice to the actual output. The formatting looks much better in the actual output.

PG

View solution in original post

5 REPLIES 5
Reeza
Super User
You need to manually combine the output into the table structure you want and then use PROC REPORT to display it.

You can use ODS OUTPUT statements to capture the outputs and then combine them using standard data step approaches.
PROC REPORT will allow you to nicely display your data.

You can get part of the way there directly with PROC TABULATE, but I find the method above more robust. There's always that one thing needed that means you need to customize things so it's easier to just control it all from the start.
paldejong
Fluorite | Level 6

I do not mind admitting that I might not have the chops to perform that specific task and the first sentence of your reply is confusing. I looked at several examples of the Proc Report statements but I have not found one that shows how to combine two variables that are originally in a horizontal orientation in one vertical column for each variable. The reason I am asking this is because I am running several regressions and I would prefer to not having to change the format of the SAS output in Excel each time.

Thank you.

Pieter

Reeza
Super User

My first sentence means, SAS doesn't do this automatically for you. If you want a table that looks like that you'll need to build it yourself. This means saving the output needed from each run, combining them if necessary and restructuring/formatting as needed for display. PROC REPORT is used only for displaying it at the end.

There's a paper from Cynthia Zender titled Creating Complex Reports that outlines how to do these type of reports. You can also find the zip file that has the programs so you can follow along.





PGStats
Opal | Level 21

Here is an example based on data step processing

 

data class;
set sashelp.class;
old = age > 13;
run;

proc logistic data=class;
class old sex;
model old = sex | height | weight / noint;
ods output parameterEstimates=pe;
run;

data pe2;
set pe; where variable is not missing;
stdErrStr = put(estimate, 10.4);
output;
call missing(variable, probChiSq);
stdErrStr = cats("(", put(stdErr, pvalue8.4), ")");
output;
run;

options missing=" ";
proc print data=pe2 noobs;
var variable stdErrStr probChiSq;
label stdErrStr = "Estimate";
run;
Variable 	stdErrStr 	ProbChiSq
Sex 	70.9267 	0.7576
  	(229.8318) 	 
Height 	0.0413 	0.7811
  	(0.1487) 	 
Height*Sex 	-0.9285 	0.7983
  	(3.6329) 	 
Weight 	0.4995 	0.3898
  	(0.5809) 	 
Weight*Sex 	-1.1886 	0.6238
  	(2.4237) 	 
Height*Weight 	-0.0083 	0.3214
  	(0.0084) 	 
Height*Weight*Sex 	0.0167 	0.6605
  	(0.0380) 	 

Note this forum interface does not do justice to the actual output. The formatting looks much better in the actual output.

PG
paldejong
Fluorite | Level 6

Thank you so much; that is exactly what I am looking for.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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