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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
That's not how SAS works, you can't access specific cells easily. Usually, you reference a column or row at the same time. You can also specify to treat groups consistently. I suggest you post some actual data that shows what you have and what you want out of that.

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

List your variable names in the var statement in proc means

 

PROC MEANS DATA=WORK.MYDATA mean;
var A2--A50; run;
amir17
Fluorite | Level 6

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?

novinosrin
Tourmaline | Level 20

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

 

 

Reeza
Super User
That's not how SAS works, you can't access specific cells easily. Usually, you reference a column or row at the same time. You can also specify to treat groups consistently. I suggest you post some actual data that shows what you have and what you want out of that.
amir17
Fluorite | Level 6
I see. Thanks for the info. Much appreciated.
Astounding
PROC Star
Do you know the names of your variables? If they are actually named a1-a99 for example you could add before the RUN statement:

var a2-numeric-a50;

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