Hello, everyone. I just learned SAS, and I have been puzzled for many days. I hope you can help me.
My data is the number of relapses(Y) in different treatment groups, and I want to compare the difference in the number of relapses in different treatment groups under the least squares mean estimation. I used the lsmeans statement to compare the differences. It outputs the difference of the estimated coefficient(Beta1-Beta3, Beta2-Beta3). But I want to get the differences of Y.
my data is like:
obs
here is my SAS codes:
proc genmod data=a;
class group(ref="3") id/param=glm;
model relapse_count=group/link=log dist=negbin offset=lntime;
repeated subject=id;
lsmeans group/cl ilink exp ;
estimate '2-1' group -1 1 0/exp;
estimate '1-3' group 1 0 -1/exp;
estimate '2-3' group 0 1 -1/exp;
run;
Since you use an offset, your model is actually on a rate rather than a count. If what you want is to estimate and test the difference in rates, then you can use the NLMeans macro as shown in this note. If you really want to compare the counts only (the numerators of the rates), then that will depend on the value of the offset. You could do that using the NLEST/NLEstimate macro (also shown in the above note), but you would need to include, in each EXP() expression, the desired offset variable value at which you want to compute the difference.
Since you use an offset, your model is actually on a rate rather than a count. If what you want is to estimate and test the difference in rates, then you can use the NLMeans macro as shown in this note. If you really want to compare the counts only (the numerators of the rates), then that will depend on the value of the offset. You could do that using the NLEST/NLEstimate macro (also shown in the above note), but you would need to include, in each EXP() expression, the desired offset variable value at which you want to compute the difference.
Thank you@StaDave.
The link contains the answer I want. But when I run the NLmeans code, I get a WARNING: No call to parse macro "NLMEANS".
Being a beginner, I don't quite know the solution to this problem. Can you help me?
As noted in red at the top of the documentation for the NLMeans and NLEST macros, these macros should be directly callable in SAS 9.4M6 or later. But if, for some reason, either of these is not found, then they can be downloaded and defined in your SAS session as discussed at the links provided above. Note that the NLMeans macro calls the NLEST macro so both are needed. You can check their availability in your SAS session and check their versions using the following calls. I suggest using the latest versions which, as noted in their documentation, are 1.9 for NLEST and 1.4 for NLMeans.
%nlest(v)
%nlmeans(v)
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.