BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
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
1 ACCEPTED SOLUTION

Accepted Solutions
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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

3 REPLIES 3
mfisher
Fluorite | Level 6
proc glm data=data;
class day;
var TimeSpent;
run;
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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;
Ksharp
Super User
Just as mfisher said.
Use ' proc glm' + ' means /schette ' statement. '/schette' is what i forgot.


Ksharp

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7593 views
  • 0 likes
  • 4 in conversation