How to print the the Somers'D in a SAS dataset? - sas

As the title suggests, I wonder about there's a way to print the Somers'D statistics and the p-value of the predictor x in a dataset.
You can get such statistics by simply running:
ODS TRACE ON;
PROC LOGISTIC DATA = BETTING.TRAINING_DUMMIES NOPRINT;
MODEL Z1 (EVENT = '1') = D_INT_LNGAP_1;
OPTIONS;
RUN;
ODS TRACE OFF;
ODS OUTPUT FITSTATISTICS=FITDS;
PROC LOGISTIC DATA = BETTING.TRAINING_DUMMIES NOPRINT;
MODEL Z1 (EVENT = '1') = D_INT_LNGAP_1;
OPTIONS;
RUN;
If I run a similar code to the one proposed here, I get only the AIC, the SIC and finally the LR stat and in the SAS log I find:
10 ODS TRACE ON;
11
12 PROC LOGISTIC DATA = BETTING.TRAINING_DUMMIES NOPRINT;
13 MODEL Z1 (EVENT = '1') = D_INT_LNGAP_1;
14 OPTIONS;
15 RUN;
NOTE: PROC LOGISTIC is modeling the probability that z1=1.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 3968 observations read from the data set BETTING.TRAINING_DUMMIES.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.07 seconds
cpu time 0.04 seconds
16
17 ODS TRACE OFF;
in the first piece of code, while in the second I find the following:
18 ODS OUTPUT FITSTATISTICS=FITDS;
NOTE: Writing HTML Body file: sashtml.htm
19 PROC LOGISTIC DATA = BETTING.TRAINING_DUMMIES NOPRINT;
20 MODEL Z1 (EVENT = '1') = D_INT_LNGAP_1;
21 OPTIONS;
22 RUN;
NOTE: PROC LOGISTIC is modeling the probability that z1=1.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: There were 3968 observations read from the data set BETTING.TRAINING_DUMMIES.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
WARNING: Output 'FITSTATISTICS' was not created. Make sure that the output object name, label,
or path is spelled correctly. Also, verify that the appropriate procedure options are
used to produce the requested output object. For example, verify that the NOPRINT
option is not used.
Some of you can suggest a way to to print such statistics in a new dataset?
Any help will be appreciated.
Thanks!

I don't know why you're not getting ODS TRACE output. I'd restart your SAS version or report it to SAS.
The tables you want are called Association and ParameterEstimates. Somer's D requires the Odds Ratio statement to be created.
ods trace on;
ods output association=somers parameterestimates=pe;
proc logistic data=sashelp.heart;
model status=ageatstart;
oddsratio ageatstart;
run;
ods trace off;

Related

How to output the standard error of odds ratio for proc logistic?

When I use the proc logistic in SAS, in the output, it return the confidence of interval and p-value of the odds ratio, how can I output the standard error of the odds ratio?
proc logistic data=edu;
model school = age sex income/ clodds=wald orpvalue;
oddsratio age;
run;
The output likes
Odds Ratio Estimates and Wald confidence interval
Point 95% Wald
Effect Estimate Confidence Limits p-value
age 1.21 0.74 2.001 < 0.01
Tip: The documentation page Proc Logistic Details -> ODS Table Names lists all the tables the procedure will produce for ODS. The ODDSRATIO ... /CL=WALD ...; statement creates an output table named OddsRatiosWald.
The ODS TRACE ON statement will also log the the table names that a Proc Step produces for ODS output.
Save the table as an output data set using the ODS OUTPUT statement.
Example:
Code from SAS samples tweaked to save ODS OUTPUT.
* Example 76.4 Nominal Response Data: Generalized Logits Model;
data school;
length Program $ 9;
input School Program $ Style $ Count ##;
datalines;
1 regular self 10 1 regular team 17 1 regular class 26
1 afternoon self 5 1 afternoon team 12 1 afternoon class 50
2 regular self 21 2 regular team 17 2 regular class 26
2 afternoon self 16 2 afternoon team 12 2 afternoon class 36
3 regular self 15 3 regular team 15 3 regular class 16
3 afternoon self 12 3 afternoon team 12 3 afternoon class 20
;
ods trace on;
ods graphics on;
ods html file='logistic.html';
proc logistic data=school;
freq Count;
class School Program(ref=first);
model Style(order=data)=School Program School*Program / link=glogit;
oddsratio program / cl=wald;
ods output OddsRatiosWald=or_program;
run;
proc print data=or_program;
title "Logistic Odds Ratios CL=Wald output data";
run;
ods html close;
ods trace off;
title;
Output data as examined by viewtable in Base SAS

Outputting p-values in SAS Proc Autoreg Procedure

i am able to output all sorts of statistics and values, however, am missing the ability to output p-values of parameter estimator significance.
I do get them in the Output window but not in my outputted tables. Here is my code
ods output PhilOul = philipps FitSummary = Stats;
proc autoreg data=ppnr_1.train outest=regression_13;
model mnos = ir_irs10y_yoyd ur_ap_yoy sav_yoyd_l1
/ stationarity=(PHILLIPS)
;
where date ge "&dev_start." and date le "&dev_end." ;
proc print data = regression_13;
run;
quit;
As you can see, I get DW-statistics (in "Stats" table), PhilipsOulier ("Philipps" table) and parameter estimates ("Regression_13") but not the significance of these parameters...
Best regards, Niels
EDIT: I used to figure out how to output p-values in PROC REG statement. Specify the TABLEOUT option. However, this option is not valid in PROC AUTOREG :-(
The p-values are in ODS output table ParameterEstimates. Change your code to be:
ods output
PhilOul = philipps
FitSummary = Stats
ParameterEstimates = Estimates
;
You can observe the ODS output tables that a procedure creates by using ODS TRACE. You only need to trace once, or if you forget :).
ODS TRACE ON;
PROC ...;
ODS TRACE OFF;

Only output the ROC curve in SAS

I am looking to create a pdf with 4 nice graphs for different analysis. My question is, how do I output only the ROC curve for my logistic regression?
I use the following code
TITLE2 JUSTIFY=CENTER "Rank ordering characteristic curve (ROC)";
ODS GRAPHICS ON;
PROC LOGISTIC
DATA = input
plots(only)=(roc(id=obs))
;
MODEL y
(Event = '1')= x
/
SELECTION=NONE
LINK=LOGIT;
RUN;
QUIT;
ODS GRAPHICS OFF;
and a dummy dataset can be imagined using this
DATA HAVE;
DO I = 1 TO 100;
Y = RAND('integer',0,1);
x = ranuni(i);
output;
end;
run;
Thanks
EDIT: just to be explicit, I'm looking to output just a plot of the ROC curve and nothing else, i.e. the tables containing the somers' D etc.
ODS SELECT ROCCURVE;
ODS SELECT allows you to control the output and include only the tables/output you want.
You can wrap your code in ODS TRACE ON, ODS TRACE OFF to find out what the table name, or check the documentation.

How to save regression coefficients to file in SAS?`

I am trying to carry out a logistic regression with SAS. I have few settings for the model, and try to compare the difference.
What I want to archieve is to output the estimated coefficients to a file. I think ODS maybe a promising way, but don't know how to use it.
Can anyone write me a simple example?
Thank you very much.
To add a bit of additional color; ODS OUTPUT <NAME>=DATASET ... ; will save the output into the specified dataset.
Use ODS TRACE get the names of output tables. Information on the tables will be written to the log.
ods trace on;
ods output ParameterEstimates=estimates;
proc logistic data=test;
model y = i;
run;
ods trace off;
For Logistic:
proc logistic data = in descending outest = out;
class rank / param=ref ;
model admit = gre gpa rank;
run;
For proc reg:
proc reg data=a;
model y z=x1 x2;
output out=b
run;
for proc glm:
ods output Solution=parameters FitStatistics=fit;
proc glm data=hers;
model glucose = exercise ;
quit;
run;
for proc reg this doesn't work for me
Use proc reg OUTEST=b
proc reg data=a outest=b;
model y=x1;
run;
other reg can get other parameters added to OUTEST.

How to obtain value of estimated parameters in SAS (proc phreg)?

How to obtain value of estimated parameters in SAS (proc phreg) ? I have been searching syntax OUTPUT and baseline but they gives only value XBETA ets.
I'm not into statistics, so I'm just guessing what value you mean - here's an example I think could help you:
ods trace on;
ods output ParameterEstimates=work.my_estimates_dataset;
proc phreg data=sashelp.class;
model age = height;
run;
ods trace off;
This is using SAS Output Delivery System component of SAS/Base.
With ods trace on;, you'll see references to parts of procedure output in SAS log:
Output Added:
-------------
Name: ParameterEstimates
Label: Maximum Likelihood Estimates of Model Parameters
Template: Stat.Phreg.ParameterEstimates
Path: Phreg.ParameterEstimates
You can refer to those (usually by Name or Path) and store them in a table with ODS OUTPUT... statement.
Look for SAS ODS user guide for more.