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!
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.
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.
@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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.