How to save regression coefficients to file in SAS?` - 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.

Related

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;

Is there a way to find predicted R-squared using PROC REG in SAS?

I am looking to have SAS calculated the predicted R-squared value using PROC REG.
You mean the R-Square? It's very easy to get.
ods output FitStatistics = FitStatistics;
proc reg data = sashelp.class;
model height = age;
quit;
ods output close;
The R-Square is located at data set FitStatistics.

SAS Ods Output for Anova

I created an Anova and want to save the mean, standard deviation, F-statistics and the p-Value in a new data set.
This is my current code:
ODS OUTPUT means=anova;
PROC ANOVA DATA= multiple_sclerosis;
CLASS ms_form;
MODEL eq5d = ms_form;
MEANS ms_form;
RUN;
quit;
ods output close;
Thanks for any help!
You can add ODS TRACE ON; before your code to see the names of the tables that it outputs. In this case, I think you want the ModelANOVA table (the second table in the Output/Results window).
ODS OUTPUT means=anova modelAnova=model;
PROC ANOVA DATA= sashelp.cars;
CLASS cylinders;
MODEL mpg_highway=cylinders;
MEANS cylinders;
RUN;
quit;
ods output close;
You have to add "outstat=" statement.
Try this:
PROC ANOVA DATA= multiple_sclerosis;
CLASS ms_form;
MODEL eq5d = ms_form;
MEANS ms_form;
OUTSTAT = <output library>.<output table>; /* <--- */
RUN;

How do I put conditions around Proc Freq statements in SAS?

I have the following statement
Proc Freq data =test;
tables gender;
run;
I want this to generate an output based on a condition applied to the gender variable. For example - if count of gender greater than 2 then output.
How can I do this in SAS?
Thanks
If you mean an output dataset, you can put a where clause directly in the output dataset options.
Proc Freq data =sashelp.class;
tables sex/out=sex_freq(where=(count>9));
run;
I'm not aware of how you can accomplish this only using proc freq but you can redirect the output to a data set and then print the results.
proc freq data=test;
tables gender / noprint out=tmp;
run;
proc print data=tmp;
where count > 2;
run;
Alternatively you could use proc summary, but this still requires two steps.
proc summary data=test nway;
class gender;
output out=tmp(where=(_freq_ > 2));
run;
proc print data=tmp;
run;

How to display sample size in PROC REG output in SAS?

My question is very simple, is there a way to display sample size in PROC REG output in SAS? I've been googling to no avail.
ods output nobs=numobs;
proc reg;
model y=x;
run;
This is what worked for me:
proc reg data=data;
model y=x;
ods select parameterestimates nobs; *can add whatever other tables you are interested in;
run;
Here is a list of tables for PROC REG: http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect051.htm