Quartz | Level 8

Calculate wage gap in one step

Right now I'm doing a (weighted) proc means by sex then doing a data step to subract women's avg from men's. There's also a few redundant steps.

I'd like to try and do it in 1 step using maybe proc tabulate? Not sure if you have any advice.

thanks!

3 REPLIES 3
Diamond | Level 26

Re: Calculate wage gap in one step

It would be hard to actually provide a solution in one step unless you show us (a portion of) your data.

But as far as advice goes, doing it in one step sometimes is harder than doing it in several steps. Again, we can't advise this without seeing your data, and without seeing your existing code.

Lastly, I ask ... why does it need to be done in one step? There are other possible more meaningful goals: efficiency of execution, readability of code. To be honest, I think doing it in one step is a false goal most of the time; it shows you are a wizard at coding, but that's rarely a goal in most business situations.

--
Paige Miller
Diamond | Level 26

Re: Calculate wage gap in one step

Also, PROC TTEST provides weighted means by group, and also computes the difference between the two groups without a need for additional programming. This may not be particularly efficient, as TTEST will also compute a lot of other things you don't want, but it still spends the time to do the calculations.

--
Paige Miller
Super User

Re: Calculate wage gap in one step

@fieldsa83 wrote:

Right now I'm doing a (weighted) proc means by sex then doing a data step to subract women's avg from men's. There's also a few redundant steps.

I'd like to try and do it in 1 step using maybe proc tabulate? Not sure if you have any advice.

thanks!

Proc tabulate will not do calculations involving resulting statistics as you would need for this.

Proc Report might depending on your actual data. However if you start getting into moderately complex comparisons such as by sex, age and some geographical area the approach in Proc Report could become quite complex and fragile.

What are "redundant steps" in your process?

I could see a proc means, proc transpose, data step and proc print or perhaps proc tabulate or report to display results as typical for this type of report.

Discussion stats
• 3 replies
• 487 views
• 2 likes
• 3 in conversation