BookmarkSubscribeRSS Feed
Epid
Fluorite | Level 6

Hello. I have following data:

Sex 1 Male; 2 Female

Work (categorical variable) 1 White collar; 2 Pink; 3 Blue collar

Pain intensity (Categorical variable with 5 choices)

IDAgeSexWorkSick daysPain intensity 
13011254
22522203
33523142
45012131
54511102

 

I wanted to run linear regression (dep var= sick days; indep var= pain intensity) weighted by age, work and sex. 

 

proc reg data=data;
weight age work sex;
model Sick days= Pain intensity/clb;
run;

 

Once I run program, my output seems to have only weight for age. 

 

How can i run regression weighted by three variables. Isn't it possible to weight by categorical variables with more than 2 levels?

 

Thanks a lot in advance.

 

epid

5 REPLIES 5
PGStats
Opal | Level 21

Usual regression (unweighted) fits a linear model that minimizes the sum of squared errors (observed - predicted values). In weighted regression, each error carries a weight in the sum of squares. So, in your example data, if you weighted by sex, prediction errors about females would be twice as important as errors for males in fitting the model (because the weights are 2:1). It is not obvious how this concept could involve more than one weight variable.

 

If this is not what you expected a weighted regression to do, please explain further.

PG
Epid
Fluorite | Level 6

Thank you very much for your quick response.

 

Does it mean that two variables cant be used as a weight in linear regression? For example,  I want to check the relation between sick days and pain intensity. So I assume that first) older age people would be more important than younger age and second) people with higher Body Mass Index (BMI) is more likely to have sick days than those with lower BMI. In that case, shouldn't I adjust (weight)  both age and BMI to build regression model for sick days and pain? If one than one variable cant be used at the same time, is there any other solution for this?

Thanks again,

 

 

ballardw
Super User

@Epid wrote:

Thank you very much for your quick response.

 

Does it mean that two variables cant be used as a weight in linear regression? For example,  I want to check the relation between sick days and pain intensity. So I assume that first) older age people would be more important than younger age and second) people with higher Body Mass Index (BMI) is more likely to have sick days than those with lower BMI. In that case, shouldn't I adjust (weight)  both age and BMI to build regression model for sick days and pain? If one than one variable cant be used at the same time, is there any other solution for this?

Thanks again,

 

 


I think you need a different procedure than proc reg. If you are looking to see how levels of a categorical variable influence the model you may be looking for Proc GLM with categorical variables on a CLASS statement to tell the procedure that is how the variables are used. Then add the variables to the MODEL statement.

Epid
Fluorite | Level 6

Thank you Ballardw, 

 

I also tried the following code to adjust the influence of sex and work type.

 

proc glm data=data;

class sex work;

weight sex work;

model Sickdays=Pain1 Pain2 Pain3 Pain4;

run;

 

It also didn't work. It said "weight by sex*sex "but even didnt produce parameter estimates. Now thinking maybe better to check the multi regression model fit including sex and work as an independent variable and weight only by age, if there is no other solution to control sex and worktype at the same time.

Thanks again.  

 

ballardw
Super User

@Epid wrote:

Thank you Ballardw, 

 

I also tried the following code to adjust the influence of sex and work type.

 

proc glm data=data;

class sex work;

weight sex work;

model Sickdays=Pain1 Pain2 Pain3 Pain4 sex work;

run;

 

It also didn't work. It said "weight by sex*sex "but even didnt produce parameter estimates. Now thinking maybe better to check the multi regression model fit including sex and work as an independent variable and weight only by age, if there is no other solution to control sex and worktype at the same time.

Thanks again.  

 


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 765 views
  • 2 likes
  • 3 in conversation