Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Using Proc GLM with Categorical Variables/How to g...

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-25-2018 04:24 PM

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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to someone456

05-26-2018 12:36 AM

What about the other interactions?

**model Medications=Sex|AgeGroups|Income;**

PG

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to someone456

05-26-2018 07:34 AM

@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=male2=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

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PaigeMiller

05-26-2018 11:28 PM

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.