BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9

data strength;
input id program$ s1 s2 s3 s4 s5 s6 s7;
datalines;
1 co 81 84 83 83 85 85 85
2 co 77 78 79 79 81 82 81
3 co 84 85 87 89 88 85 86
4 co 74 75 78 78 79 78 78
5 co 76 77 77 77 77 76 76
6 co 84 84 86 85 86 86 86
7 co 79 80 79 80 80 82 82
8 co 78 78 77 76 75 75 76
9 co 78 80 77 77 75 75 75
10 co 84 85 85 85 85 83 82
11 co 83 83 85 85 86 87 87
12 RI 79 82 82 83 84 84 82
13 RI 88 89 91 90 93 93 95
14 RI 83 83 84 83 84 86 86
15 RI 81 81 82 82 82 83 85
16 RI 87 88 90 89 89 91 93
17 RI 80 82 83 85 86 88 88
18 RI 82 83 84 84 83 85 87
19 RI 84 85 85 85 86 88 90
20 RI 80 80 82 83 83 84 85
21 RI 85 87 88 88 90 90 91
22 RI 87 88 88 87 87 86 86
;
run;
proc print data=strength;
run;
proc means data=strength mean std var;
var s1 s2 s3 s4 s5 s6 s7;
by program;
run;


1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

You have to sort your data appropriately first

 

proc sort data=strength;
    by program;
run;

proc means data=strength mean std var;
    by program;
    var s1 s2 s3 s4 s5 s6 s7;
run;

View solution in original post

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

You have to sort your data appropriately first

 

proc sort data=strength;
    by program;
run;

proc means data=strength mean std var;
    by program;
    var s1 s2 s3 s4 s5 s6 s7;
run;
tianerhu
Pyrite | Level 9

Thank you

tianerhu
Pyrite | Level 9

thank you

ballardw
Super User

The output would look slightly different but you can use a CLASS statement instead of BY which will not generate the not sorted by BY variables error.

 

proc means strength=have mean std var;
   var s1 s2 s3 s4 s5 s6 s7;
   class program;
run;

If you have large data with lots of values for the class variables there can be performance issues.

tianerhu
Pyrite | Level 9

thank you

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1244 views
  • 1 like
  • 4 in conversation