BookmarkSubscribeRSS Feed
ralphbenno
Fluorite | Level 6

I finally was able to use the import wizard to convert my excel table into SAS. First time I am using excel.with data

 

I have attached my excel

I would like mean and standard deviation per column and rows.

 

Cant do it correctly./Can anybody provide with simple code.

 

thank you

 

 

1 REPLY 1
Reeza
Super User

Sure, you likely want to be using the STACKODS options. 

 

If you run these examples and follow them through, you'll see the different kinds of output you can get. In this particular case the analysis is grouped by ID and feature, so different statistics for each ID level. If you don't need this, ignore the BY statement. 

 

*Create summary statistics for a dataset by a 'grouping' variable and store it in a dataset;

*Generate sample fake data;
data have;
	input ID          feature1         feature2         feature3;
	cards;
1               7.72               5.43              4.35
1               5.54               2.25              8.22 
1               4.43               6.75              2.22
1               3.22               3.21              7.31
2               6.72               2.86              6.11
2               5.89               4.25              5.25 
2               3.43               7.30              8.21
2               1.22               3.55              6.55

;
run;

*Create summary data;
proc means data=have noprint;
	by id;
	var feature1-feature3;
	output out=want median= var= mean= /autoname;
run;

*Show for display;
proc print data=want;
run;

*First done here:https://communities.sas.com/t5/General-SAS-Programming/Getting-creating-new-summary-variables-longitudinal-data/m-p/347940/highlight/false#M44842;
*Another way to present data is as follows;

proc means data=have stackods nway n min max mean median std p5 p95;
    by id;
    var feature1-feature3;
    ods output summary=want2;
run;

*Show for display;
proc print data=want2;
run;

https://github.com/statgeek/SAS-Tutorials/blob/master/proc_means_basic.sas

 

And some other useful ones here:

https://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=p13nj9tbyfmmwyn1az938n5w...

Note there are more examples, click through the menu on the left hand side to see the other variations. 

 

Specifically STACKODS here:

https://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=p17h6q7ygvkl1sn13qzf947d...

 


@ralphbenno wrote:

I finally was able to use the import wizard to convert my excel table into SAS. First time I am using excel.with data

 

I have attached my excel

I would like mean and standard deviation per column and rows.

 

Cant do it correctly./Can anybody provide with simple code.

 

thank you

 

 


 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 609 views
  • 0 likes
  • 2 in conversation