SAS proc mixed model: NO difference observed when changing the variable in the left side of the model - sas

I run a mixed model according to the PROC MIXED step in SAS. My code is like this below:
proc mixed data=inds;
class subject arm(ref='C') ;
model aval =base arm avisitn arm*avisitn /s ;
random subject ;
repeated / subject=subject ;
lsmeans arm / diff cl at avisitn=0;
lsmeans arm / diff cl at avisitn=1;
lsmeans arm / diff cl at avisitn=2;
ods output diffs=diff ;
run;
Then I change the variable in the model option at the left side of the equation like this:
proc mixed data=inds;
class subject arm(ref='C') ;
model chg =base arm avisitn arm*avisitn /s;
random subject ;
repeated / subject=subject ;
/* lsmeans arm / pdiff cl at avisitn=0;*/
lsmeans arm / pdiff cl at avisitn=1;
lsmeans arm / pdiff cl at avisitn=2;
ods output diffs=diff1 ;
run;
I just change the variable from the value at each time point to the change from baseline.
Then I find that the Differences of Least Squares Means is the same.
I do not know how this works.
Can anyone tell me why?
A explanation from the model and a suggestion from the code so that I can see why I get the same results.

Related

How to put P-Values and R-squared into a SAS data set at the same time?

I'm running this code in SAS:
%let control = A;
%let test = B C D E F;
ods output ParameterEstimates = parms;
proc reg data=reg_data outest=work.model tableout;
model &control = &test / selection= rsquare adjrsq;
run;
proc sql;
create table max_r_square as
select *
from work.model
order by _ADJRSQ_ desc, _RSQ_ desc;
quit;
It effectively goes through all of the combinations of the test variable and then drops the information including R-Squared into a data set. From there I can choose the model that has the highest R-Squared.
My problem is, I can't find a way for the table to include R-Squared and P-Values at the same time while going through all combinations of the test variable.
Taking out the rsquare and adjrsq options gets the p-values in a table, but it keeps SAS from running code on all of the combinations.
I've been looking through the proc reg arguments and options and haven't found anything that works so far.
Is there a way to have SAS run a regression on all combinations of input variables and output R-Squared and P-Values into the same table?

SAS: Different Odds Ratio from PROC FREQ & PROC LOGISTIC

I'm working on a project and have run into an expected issue. After running PROC LOGISTIC on my data, I noticed that a few of the odds ratios and regression coefficients seemed to be the inverse of what they should be. After some investigation using PROC FREQ to run the odds ratios, I believe there is some form of error with the odds ratios from PROC LOGISTIC.
The example below is of the response variable "MonthStay" and one of the variables in question "KennelCough". MonthStay = Y and the event of interest is KennelCough = N.
I don't know how to remedy this suspected error. Am I missing something in my code to get the correct calculations? Or am I totally misunderstanding what's going on? Thanks!
Here is the PROC FREQ code and result:
proc freq data = capstone.adopts_dog order = freq;
tables KennelCough*MonthStay / relrisk;
run;
Here is the PROC LOGISTIC CODE and results:
proc logistic data = capstone.adopts_dog plots(only)=(roc(id=prob) effect);
class Breed(ref='Chihuahua') Gender(ref='Female')
Color(ref='Black') Source(ref='Stray') EvalCat(ref='TR') SNAtIn(ref='No')
FoodAggro(ref='Y') AnimalAggro(ref='Y') KennelCough(ref='Y') Dental(ref='Y')
Fearful(ref='Y') Handling(ref='Y') UnderAge(ref='Y') InJuris(ref='Alameda County')
InRegion(ref='East Bay SPCA - Dublin') OutRegion(ref='East Bay SPCA - Dublin')
/ param=ref;
model MonthStay(event='Y') = Age Gender Breed Weight Color Source EvalCat SNatIn
NumBehvCond NumMedCond FoodAggro AnimalAggro KennelCough Dental Fearful
Handling UnderAge Injuris InRegion OutRegion
/ lackfit aggregate scale = none selection = backward rsquare;
output out = probdogs4 PREDPROBS=I reschi = pearson h = leverage;
run;
Class Level Info
Odds Ratios Estimates
In Proc Freq, you are calculating unadjusted odds ratio while in proc logistics, all odds ratio were adjusted for covariates included in the logistic regression model

Break After & R Break

I am creating a report using proc report. My syntax runs fine but it doesnot shows the results of R break & After break in the output report. Thanks in advance
ods pdf file = "D:\New folder (2)\Assignment\Case_Study_1\Detail_Report.pdf";
proc report data = Cs1.Detailed_Report headline nowd ls = 256 ps = 765;
Title 'Olympic Pipeline (LONDON) - by Probability As of 17th November 2012';
column Probability Account_Name Opportunity_Owner Last_Modified_Date Total_Media_Value Digital_Total_Media_Value Deal_Comments;
where Probability > 0;
define Probability/group Descending 'Probability';
define Account_Name/order 'Client';
define Opportunity_Owner/order 'Champ';
define Last_Modified_Date/order format = MMDDYY. 'Modified';
define Total_Media_Value/order format = dollar25. 'Tot_Budget';
define Digital_Total_Media_Value/order format = dollar25. 'Digital_Bugt';
define Deal_Comments/order 'Deal_Comments';
break after Probability/ summarize suppress ol ul;
rbreak after / summarize ol ul;
run;
ods listing close;
ods pdf close;
Your main problem is that you don't have anything for the summarization to do. All of your columns are "ORDER" columns, which is probably not what you want. This is a common confusion in PROC REPORT; ORDER actually can be used in two different ways.
ORDER column type (vs. ANALYSIS, GROUP, ACROSS, COMPUTED, etc.)
ORDER= instruction for how to order data in a column (ORDER=DATA, ORDER=FORMATTED, etc.)
You can instruct SAS how to order a column without having to make it an ORDER column (which is basically similar to GROUP except it doesn't condense extra copies of a value if there are more than one).
If you want RBREAK or BREAK to do anything, you need to have an ANALYSIS variable(s); those are the variables that you want summaries (and other math) to work on.
Here is an example of this working correctly, with analysis variables. You need to tell SAS what to do, also, when summarizing them; mean, sum, etc., depending on what your desired result is.
ods pdf file = "c:\temp\test.pdf";
proc report data = sashelp.cars headline nowd ls = 256 ps = 765;
column cylinders make model invoice mpg_highway mpg_city;
where cylinders > 6;
define cylinders/group Descending;
define make/order;
define model/order;
define invoice/analysis sum;
define mpg_highway/analysis mean;
define mpg_city/analysis mean;
break after cylinders/ summarize suppress ol ul;
rbreak after / summarize ol ul;
run;
ods pdf close;

Equivalent of lsmeans for proc qlim in SAS?

I'm running a censored tobit model (continuous outcome ranging from 0 to 100, transformed from a proportion) in SAS and would like to obtain mean effects + 95% CIs across categories of an independent variable. Is there a command one can use to output that, similar to lsmeans / cl in proc glm? For reference, this is what my code looks like:
proc qlim data = mydata;
class var1;
model outcomevar = var1;
endogenous outcomevar ~ censored (lb=0 ub=100);
ods output parameterestimates=pe;
run;
Thank you!

SAS Sequential (Hierarchical) Regression: Change in R2 between models and F test

I am wanting to perform Sequential (Hierarchical) Regression in SAS where I dictate the clusters of variables added to the model. I'd then like to see the change in R2 (R square) between the models and an F test for significance.
Here's example syntax of the models I'd like to compare:
proc reg data=pt8;
Covariates: model y=jz lnWg iq;
Linear: model y=R RM jz lnWg iq;
Quadratic: model y=R RM RM2 R2 RInt jz lnWg iq;
run;
quit;
Is there a way to use ANOVA or the built-in forward selection where I can dicatate how I'm adding variables ({R, RM} for the "Linear" model and then {RM2, R2, RInt} for the "Quadratic" model)? Your syntax is greatly appreciated.
You can use the include= statement to force certain variable into the model when it does forward selection. You can get a summary table of the models with the ods output statement. Make sure that you have ods graphics on set, and noprint is not used in PROC REG.
proc reg data=pt8;
Covariates: model y=jz lnWg iq / selection = forward;
Linear: model y=R RM jz lnWg iq / selection = forward include=2;
Quadratic: model y=R RM RM2 R2 RInt jz lnWg iq / selection=forward include=5;
ods output SelectionSummary;
run;
include is an integer that tells PROC REG to keep the first n variables into the model, then perform forward selection on the remaining variables. You will also have a table named SelectionSummary with fit statistics for each model and step in the selection process.
Alternatively, you can group variables with curly brackets, and PROC REG will treat them all as one provided they meet certain tolerance values and don't make the matrix singular. It automatically removes the variable that breaks the model if this is the case. You can optionally name those groups with groupnames=.
proc reg data=pt8;
Covariates: model y=jz lnWg iq / selection = forward;
Linear: model y={R RM} jz lnWg iq / selection = forward;
Quadratic: model y={R RM RM2 R2 RInt} jz lnWg iq / selection=forward;
ods output SelectionSummary;
run;
If you have interaction effects that you would like to measure, PROC GLMSELECT has many more options than PROC REG for how you'd like to add or remove those effects. Just don't forget to turn on the showpvalues option - it's the only procedure where they don't show p-values by default. What, you mean you don't know every probability from every type of F distribution? :)