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
Super User

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
Super User

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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