BookmarkSubscribeRSS Feed
Rick_SAS
SAS Super FREQ

The simplest explanation for why your Intercept estimate differs from your colleague is that you used different centering values when you standardized the covariate (CRP_A). When you called PROC STDIZE, you centered by the data mean and data stdDev. If your colleague centered by another value, he/she would get a different intercept estimate.

 

Here is an example that shows the same PROC GLM statements. The first analysis centers the data by subtracting the value 20. The second call centers the X variable by subtracting the sample mean. All estimates are the same except for the Intercept.

 

data class;
set sashelp.class;
ageCat = (Age<13);
heightCat = (Height<62);
call streaminit(1);
x = rand("Normal", 20, 1);
run;

title "Colleague Analysis";
proc stdize data=class out=class1 add=-20;
var x;
run;

proc glm data=class1 plots=none;
class Sex ageCat heightCat;
model weight = x Sex ageCat heightCat / solution;
ods select ParameterEstimates;
quit;

/*------------------*/
proc stdize data=class out=class2;
var x;
run;

title "My Analysis";
proc glm data=class2 plots=none;
class Sex ageCat heightCat;
model weight = x Sex ageCat heightCat / solution;
ods select ParameterEstimates;
quit;

khem
Calcite | Level 5

Hello @Rick_SAS ,

 

Thanks for the explanation,

I tried to understand your example and compare it with my code,

Looks like my code is similar to your second example (please correct me if i am wrong),

If I want to get the same intercept estimate like my colleague (they used SAS enterprise and i don't have their code), do i need to remove the method part? 

AS you defined X= rand...., i cant do guess for CRP_A

x = rand("Normal", 20, 1);

or add = -20

I am sorry, but i don't know what change to i need to make? i am still a newbie to SAS.

 

Please guide me, what change is needed in my code?

Thanks,

Khem

Rick_SAS
SAS Super FREQ

> If I want to get the same intercept estimate like my colleague

> (they used SAS enterprise and i don't have their code),...

 

1. If you want to get the same estimate, the easiest solution is to contact your colleague. This will enable you to understand what is happening.

2. If the problem is caused by different centering of X (and we do not know for certain that it is), then both models will give the same predicted variables. Only the parameterization is different, but they represent the same predictive model. Thus there is really no need to get the same estimates.

3. If you can't do #1 and you aren't convinced by #2 and you insist on getting the same answer, then center CRP_A by using the value -1.681563224. That is, use 

ADD = -1.681563224

on the PROC STDIZE statement.

 

Be aware that #3 is a hack. The best solution is #1.

khem
Calcite | Level 5

Hi @Rick_SAS ,

 

Thanks for the tips,

I added ADD =  -1.681563224 but i couldn't get the same intercept estimate (please see the image). By the way, how do you calculate the value for  ADD?

I asked my colleague for the details, how i can get the code,

Just for curiosity, does it possible to get code from SAS enterprise guide version?

 

khem_0-1597424944674.png

Thanks,

Khem

 

khem
Calcite | Level 5

Hi @Rick_SAS @PaigeMiller 

I am doing ANCOVA with three categorical variable. But i am confused about how to represent the results in a graph/plot,

 

a box/scatter, i dont know how it works, this is my first time doing using SAS studio,

Please someone can guide me on this, i would appreciate the support,

Thanks,

 

khem_1-1602219122133.png

 

PaigeMiller
Diamond | Level 26

@khem wrote:

Hi @Rick_SAS @PaigeMiller 

I am doing ANCOVA with three categorical variable. But i am confused about how to represent the results in a graph/plot,

 

Can you explain further? What plot would you want? SAS provides many different default plots, perhaps you should try them and see if they meet your needs.

 

Use ods graphics on; and then in the PROC statement, add in the option PLOTS=ALL

--
Paige Miller
khem
Calcite | Level 5

Hi @PaigeMiller ,

I dont know exactly how to represent the significant changes in a graph,

 

Please see my attached code

 

khem_0-1602247317020.png

I am able to get only diagnostic plots, even after choosing in options section for all kind of plots,

Please let me know if something i am doing wrong,

Thanks

 

PaigeMiller
Diamond | Level 26

Try using PLOTS=ALL and see if one of those plots is something you want. Otherwise, you need to show us an example of a plot you want. Saying "how to represent the significant changes" is not specific enough.

 

Also, please in the future copy your code as text (not as a screen capture) and paste it into the window that appears when you click on the "running man" icon here in the SAS Communities.

--
Paige Miller
khem
Calcite | Level 5

Hi @PaigeMiller ,

Thanks for the suggestion, i am sorry about the image,

Here is my code, when i ran this code, i got diagnostic, mean and residual images,

Since i am new in this analysis and running three different categorical variables (diets) and hoping to see their effect in a figure before and after bacterial (lactococcus) treatment.

 

Please let me know if it is possible or not.

Meanwhile, i will do more research to show you an example figure (as of now i haven't found for three categorical), so that might be helpful.

Thanks

 

 

proc glm data=work._ancova_stdize PLOTS=ALL;
class Meat Soda Fish;
model _after_g__Lactococcus= _g__Lactococcus Meat Fish Soda/solution;
%makeintest;
%makeslest;
lsmeans Meat / adjust=tukey pdiff alpha=.05 plots=(diffplot meanplot(cl) );
output out=work.Ancova_stats p=predicted lclm=lclm uclm=uclm / alpha=.05;
ods graphics on;
run;
quit;
proc delete data=work._ancova_stdize;
run;

 

PaigeMiller
Diamond | Level 26

... and hoping to see their effect in a figure before and after bacterial (lactococcus) treatment.

 

The DIFFPLOT plots ought to show you the effects of this treatment. According to your code, you should be seeing these plots in the output.

--
Paige Miller
khem
Calcite | Level 5

Do you @PaigeMiller mean this attached plot?

If yes, i got only for one categorical variable (meat). Please can you suggest how can i add the rest of the two other categorical variables?

 

 

khem_0-1602251700473.png

 

PaigeMiller
Diamond | Level 26

You need to include variable _g__Lactococcus in the LSMEANS statement.

--
Paige Miller
khem
Calcite | Level 5

Thanks for the link, this is useful,

 

I followed your instruction for lsmeans

but now DIFFPLOT disappear, my code is in the below

 

proc stdize data=WORK.IMPORT method=mean out=work._ancova_stdize;
var _g__Lactococcus;
run;

proc glm data=work._ancova_stdize PLOTS=all;
class Meat Soda Fish;
model _after_g__Lactococcus= _g__Lactococcus Meat Fish Soda/solution;
%makeintest;
%makeslest;
lsmeans Meat _g__Lactococcus / adjust=tukey pdiff alpha=.05 plots=(diffplot meanplot(cl) );
output out=work.Ancova_stats p=predicted lclm=lclm uclm=uclm / alpha=.05;
ods graphics on;
run;
quit;
proc delete data=work._ancova_stdize;
run;

PaigeMiller
Diamond | Level 26

I don't know why the plot would disappear in this case.

 

However, you can do some simple debugging. What happens if your remove MEAT from the LSMEANS? What happens if you have an LSMEANS for MEAT and in the same PROC GLM, another LSMEANS for _g__Lactococcus?

--
Paige Miller
khem
Calcite | Level 5

I ran this code and i could see all three categorical variables in three different DIFFPLOT. Thanks

 

proc stdize data=WORK.IMPORT method=mean out=work._ancova_stdize;
var g__RFN20;
run;

proc glm data=work._ancova_stdize PLOTS=all;
class Meat Soda Fish;
model after_g__RFN20= g__RFN20 Meat Soda Fish/solution;
%makeintest;
%makeslest;
lsmeans Soda Meat Fish / adjust=tukey pdiff alpha=.05 plots=(diffplot meanplot(cl) );
output out=work.Ancova_stats p=predicted lclm=lclm uclm=uclm / alpha=.05;
ods graphics on;
run;
quit;

proc delete data=work._ancova_stdize;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 30 replies
  • 2426 views
  • 3 likes
  • 3 in conversation