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

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.

Related

Create a variable dataset out of proc contents

How to use ODS TRACE to identify name of the PROC CONTENTS results output object that contains the variable name, type, length, format and informat, and save these results as new SAS datasets.
my code:
ods select Variables;
proc contents data=mylib.hotel1 out=work.h1;
run;
ods select default;
but output dataset is different from result.
There is no need to select the ODS table since out= already contains this information. If you really do want to use ODS, you can identify the table in the log with ods trace.
ods trace on;
proc contents data=sashelp.cars;
run;
ods trace off;
Check the log and you will see the dataset containing all variables:
Output Added:
-------------
Name: Variables
Label: Variables
Template: Base.Contents.Variables
Path: Contents.DataSet.Variables
-------------
You can save this with the ods output statement in proc contents.
proc contents data=sashelp.cars;
ods output variables=variables;
run;
You will receive an output dataset called variables.

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;

PROC MEANS - Save table shown in results and not in Output Data

I have the following code to produce descriptive statistics:
proc means data=sashelp.cars;
var Horsepower Weight Length;
output out = cars_stats mean = std = /autoname;
run;
I would like to get the table shown in the Results tab in the Output Data as I export the tables to Excel later on.
At the moment I get the following in the results:
But I get this in the Output Data tab.
How could I get the table from the Results in the Output Data?
Proc MEANS with option STACKODSOUTPUT will produce the same desired table.
ods select none;
proc means data=sashelp.cars stackodsoutput;
var Horsepower Weight Length;
ods output summary = cars_stats_stacked;
run;
ods select all;
ods to the rescue!
First run your code like this:
ods trace on;
proc means data=sashelp.class;
var Weight Height;
output out = class_stats mean = std = /autoname;
run;
ods trace off;
Then check the log:
Output Added:
-------------
Name: Summary <-- We want this bit
Label: Summary statistics
Template: base.summary
Path: Means.Summary
-------------
Then re-run like this:
ods select none;
ods output summary = class_summary;
proc means data=sashelp.class;
var Weight Height;
output out = class_stats mean = std = /autoname;
run;
ods select all;
This approach allows you to capture any output from any proc that would normally be displayed in the results area as a sas dataset instead.

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.

ods output in proc logistic

I am running a proc logistic with selection =score , to get the best model based on chi-square value. Here is the code
options symbolgen;
%let input_var=ABC_DEF_CkkkkkedHojjjjjerRen101 dept_gert home_value
child_household ;
ods output bestsubsets=score;
proc logistic data=trail;
model response(event='Y')=&input_var
/ selection=score best=1;
run;
The output dataset named score has been generated through ods output. Below is the image of the data set.
score data set image
In the score dataset, in the "variables included in model" column, you can only see a part of variable name "ABC_DEF_CkkkkkedHojjjjjerRen101" and not the entire name. May I know why is this happening and how do I get the entire variable name. Please let me know
Add NAMELEN=32 to your proc logistic statement.