Hi everyone,
Challenge: I wanna get the differences in revenues between different management types, in different regions and time periods.
Problem: These are the LS-Means tables and the code I used to get them. I'm interested in the estimate in Table 1 (red), but I'm not sure what it means in terms of dollar revenues (blue) in Table 2? I understand it's the difference in the estimate but, admittedly, I don't get what the estimate refers to, as I look to the mean in dollars.
SAS version: 9.4
Thanks a lot.
Table 1: Differences of Period*Management*Region Least Squares Means | ||||||||||||
Period | Management | Region | _Period | _Management | _Region | Estimate | Standard Error | z Value | Pr > |z| | Alpha | Lower | Upper |
3 | 1 | 3 | 3 | 1 | 2 | -0.6019 | 0.02224 | -27.07 | <.0001 | 0.05 | -0.6455 | -0.5583 |
Table 2: Period*Management*Region Least Squares Means | |||||||||||||
Period | Management | Region | Estimate | Standard Error | z Value | Pr > |z| | Alpha | Lower | Upper | Mean | Standard Error | Lower Mean | Upper Mean |
3 | 1 | 3 | 5.7928 | 0.01699 | 340.89 | <.0001 | 0.05 | 5.7595 | 5.8262 | 327.94 | 5.5729 | 317.2 | 339.05 |
3 | 1 | 2 | 6.3948 | 0.0144 | 444.09 | <.0001 | 0.05 | 6.3665 | 6.423 | 598.7 | 8.6211 | 582.04 | 615.84 |
Code:
proc genmod data=test order=formatted;
class Store Period Management Region / desc param=glm;
model Revenue = Management Period Region Management*Period*Region /link=log dist=gamma;
repeated subject=Store/type=ind;
lsmeans Management Region Period Management*Period*Region /ilink lines means diff cl;
slice Management*Period*Region /nof ilink sliceby=Management diff exp cl;
run;
The values you see under "Estimate" in both tables are transformed to different units by the log transformation. To understand the values in real units, you have to reverse the transformation.
The values you see under "Estimate" in both tables are transformed to different units by the log transformation. To understand the values in real units, you have to reverse the transformation.
Thank you, Paige. This is a helpful one step closer. I reversed the natural log and it works for the means but, unfortunately, not for the difference.
Natural log (the estimates from the model) | Exp (reversing the natural log from the left column) | Means (How it should be, per the means column) | |
Region 2 | 6.394760638 | 598.7 | 598.7 |
Region 3 | 5.792830665 | 327.94 | 327.94 |
Difference | 0.601929973 | 1.825639 | 270.76 |
-0.60192997 | 0.547753 |
As you can see, the difference is not reverting back to how it should be. I tried both the negative and the absolute values and it still misses the mark. So I have two follow up questions if you don't mind:
- Should I be reversing the difference in a different way?
- Is there a way for SAS to just give me the numbers I'm looking for (in dollars here) instead of their natural logarithm?
Thank you.
Follow-up: I got the first question. The difference here is the natural log of the percentage of (Region 3 mean) to (Region 2 mean).
(54.77% , -0.60193).
This leaves the second question open: Is there a more straightforward way? Am I doing something wrong?
Thank you.
I think your final answer is correct. Is there a different way? Not off the top of my head, because the log of a difference is not equal to the difference of the logs.
Thank you, Paige. You've been most helpful as always.
To All: I'll leave my earlier wrong post up there so the evolution of thought is complete for others in the community. If it's preferable to just keep the right answer, please feel comfortable to let me know.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.