I imported my .xlsx file into SAS and have no problem calculating the mean for the entire sheet using the below code:
PROC MEANS DATA=WORK.MYDATA;
run;
But what code do I add if I want to calculate the mean just for a specified range of cells (e.g. A2-A50)? I'm working with version 9.2.
List your variable names in the var statement in proc means
PROC MEANS DATA=WORK.MYDATA mean;
var A2--A50;
run;
I don't have any variables actually named "A2" or "A50." I meant the cells A2, A3, A4, etc. within an Excel spreadsheet. Any advice on this?
run a proc contents on your imported dataset
like
PROC contents DATA=WORK.MYDATA;
run;
Then you should be able to get the name of the variables to list in the var statement
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.