Programming the statistical procedures from SAS

Dealing with CLASS with more than 2 variables

Accepted Solution Solved
Reply
N/A
Posts: 0
Accepted Solution

Dealing with CLASS with more than 2 variables

Hi All,

I have a ' day' variable and it is divided in 'Morning' , 'Noon' and 'Evening'. I have also the 'TimeSpent' in each of these parts. I want to test if there is any statistical difference in the mean time spent in each of the three parts of the 'day'. When I use:-

proc ttest data=data;
class day;
var TimeSpent;
run;

Error:-

The CLASS variable has more than two levels.

Kindly guide how to deal with this.

Kind Regards,
Kritanjli

Accepted Solutions
Solution
‎10-11-2017 11:31 AM
Valued Guide
Valued Guide
Posts: 684

Re: Dealing with CLASS with more than 2 variables

Actually, it should be:
proc glm data=data;
class day;
model TimeSpent = day;
lsmeans day / pdiff;
run;

Note: you may have clustering with your data, if you are recording/measuring the same individuals at each of these times (a type of repeated measures). That is, with three values per subject (I call it id here). Would have to know more information, but you could handle in a simple way, if
proc mixed data=data;
class id day;
model TimeSpent = day;
random id;
lsmeans day / pdiff;
run;

View solution in original post


All Replies
Contributor
Posts: 58

Re: Dealing with CLASS with more than 2 variables

Posted in reply to deleted_user
proc glm data=data;
class day;
var TimeSpent;
run;
Solution
‎10-11-2017 11:31 AM
Valued Guide
Valued Guide
Posts: 684

Re: Dealing with CLASS with more than 2 variables

Actually, it should be:
proc glm data=data;
class day;
model TimeSpent = day;
lsmeans day / pdiff;
run;

Note: you may have clustering with your data, if you are recording/measuring the same individuals at each of these times (a type of repeated measures). That is, with three values per subject (I call it id here). Would have to know more information, but you could handle in a simple way, if
proc mixed data=data;
class id day;
model TimeSpent = day;
random id;
lsmeans day / pdiff;
run;
Super User
Posts: 10,194

Re: Dealing with CLASS with more than 2 variables

Posted in reply to deleted_user
Just as mfisher said.
Use ' proc glm' + ' means /schette ' statement. '/schette' is what i forgot.


Ksharp
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 4033 views
  • 0 likes
  • 4 in conversation