BookmarkSubscribeRSS Feed
someone456
Calcite | Level 5

Hi everyone. I am new-ish to using SAS and am hoping for some help on if my code is correct for what I am after. I have the following variables:

 

Medications: the total number of medications taken per person

 

Sex 
1=male

2=female

 

AgeGroups

1=20-25

2=26-29

3=30-34

 

Interaction between Sex and AgeGroups:

AgeGroups*Sex

 

Income

1=Less than 20k

2=20,000 – 49,999

3=50,000 – 79,999

4=80,000 – 99,999

5=100,000 or more

 

I want to find out if any of the categorical demographic variables have a significant effect on the number of medications. Then I want to find out where the significant differences are between groups. I am using linear regression. After some Google searching, I have come up with the following code. Is it correct to get what I am looking for? Thanks.

 

proc glm data=mydata;
class Sex AgeGroups Income;
model Medications=Sex AgeGroups Income AgeGroups*Sex /solution;
lsmeans Sex AgeGroups Income AgeGroups*Sex /adjust=scheffe;
run; quit;

3 REPLIES 3
PGStats
Opal | Level 21

What about the other interactions?

 

model Medications=Sex|AgeGroups|Income;

 

PG
PaigeMiller
Diamond | Level 26

@someone456 wrote:

Hi everyone. I am new-ish to using SAS and am hoping for some help on if my code is correct for what I am after. I have the following variables:

 

Medications: the total number of medications taken per person

 

Sex 
1=male

2=female

 

AgeGroups

1=20-25

2=26-29

3=30-34

 

Interaction between Sex and AgeGroups:

AgeGroups*Sex

 

Income

1=Less than 20k

2=20,000 – 49,999

3=50,000 – 79,999

4=80,000 – 99,999

5=100,000 or more

 

I want to find out if any of the categorical demographic variables have a significant effect on the number of medications. Then I want to find out where the significant differences are between groups. I am using linear regression. After some Google searching, I have come up with the following code. Is it correct to get what I am looking for? Thanks.

 

proc glm data=mydata;
class Sex AgeGroups Income;
model Medications=Sex AgeGroups Income AgeGroups*Sex /solution;
lsmeans Sex AgeGroups Income AgeGroups*Sex /adjust=scheffe;
run; quit;


Your question about differences between groups is answered by the LSMEANS statement. So I think this is the correct code.

--
Paige Miller
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

I agree with @PaigeMiller that you are on the right track.

 

I agree with @PGStats that you need to consider whether to exclude other potential interactions among the fixed effects (and be able to justify their exclusion).

 

In addition, I would think of this as an ANOVA rather than a regression. Of course ANOVA is really just a special case of regression, but there are things we can apply in ANOVA models that we don't apply in regression (like LSMEANS as @PaigeMiller suggested). ANOVA models have assumptions (notably, normality and homogeneity of variance and independence) that you would need to assess for your analysis. SAS® for Linear Models, Fourth Edition is an excellent resource; these are topics that are also covered extensively in courses, and so there are resources available on the internet, in books, etc.

 

I hope this helps.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 5349 views
  • 2 likes
  • 4 in conversation