Subtracting median from variables based on groups

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Jesseuva
Posts: 2
Joined: Tue Jan 27, 2015 1:50 pm

Subtracting median from variables based on groups

Postby Jesseuva » Tue Jan 27, 2015 1:58 pm

Hello,

Sorry if my subject is not clear. I have a problem with my data when trying to do industry adjustment in my master's thesis. I have data as follows:

SIC Tobins q CapEx1 Capex3 Empl1
3845 1,103 -1,289 -0,745 -0,977
3845 1,187 -0,661 0,374 -0,912
3842 1,309 -0,683 -0,313 -0,905
3842 1,112 -0,654 0,219 -0,968
3833 1,061 -1,048 -1,055 -1,000
3833 0,989 -0,268 -1,304 -1,000
3833 0,960 -1,426 -1,514 -0,906

SIC is the grouping variable. I need to subtract the median of all the variables from the observations when the medians are based on groups. So for example for group 3845 I would calculate the median of Tobins q for those two observations (1,103 and 1,187) and then subtract the median from those same two observations. This has to be done for every group and every variable. How could this be done in SPSS?

Thank you for your help in advance.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Subtracting median from variables based on groups

Postby GerineL » Tue Jan 27, 2015 3:41 pm

you can use the aggregate function (data -> aggregate), use SIC as break variable, and select "median" instead of the default "mean".
this gives you a variable with the medians for each group.

Then, you can just use the compute function to substract this from the original variable.

Good luck!
Jesseuva
Posts: 2
Joined: Tue Jan 27, 2015 1:50 pm

Re: Subtracting median from variables based on groups

Postby Jesseuva » Wed Jan 28, 2015 12:06 pm

This worked perfectly! Thank you very much.

Who is online

Users browsing this forum: No registered users and 1 guest

cron