BookmarkSubscribeRSS Feed
MarvelJJ
Calcite | Level 5

I am attempting to create a macro that will average the variables in column "Assignment1"  but I am unable to get it to work.  

 

Grades.csv

NameGenderAssignment1Assignment2Assignment3Assignment4
AldrinM98568194
BeckyF1005410099
CarlM95694893
DaphneF57798246
EriksenM83987285
FrankM46897867
GaryM86837287
HobbsM68578273
IsabellaF98858863
JeanetteF74927848
KevinM81616287
LilyF49875297
MickeyM66637575
NoraF66474288
OprahF92865259
PatriceF511007975
QuinnF60774284
RobinF54418965
StellaF61505389
TracyF54727186
UrsulaF80809970
VictoriaF52594684
WendyF50476463
XanderM94456691
YasmineF84687793
ZoeyF64407171

 

The code I have is :

%macro average(variable=);
proc means data=work.grades mean;
var &variable;
run;
%mend;

%average(variable=Assignment1);

I am using SAS University addition and I cannot figure out what I am doing wrong.  Thank you for any help.  I am am new to SAS. 

3 REPLIES 3
Astounding
PROC Star
Your code looks OK.

Examine the log to see what guidance it provides. The answer is likely to be simple. For example, perhaps you have a csv file named GRADES but never created a SAS data set named GRADES.
Shmuel
Garnet | Level 18

haven't you miss the output statement ?

%macro average(variable=);
	proc means data=work.grades mean;
		var &variable;
           output out=mean_of_&variable;
	run;
%mend;

%average(variable=Assignment1);
Kurt_Bremser
Super User

The SAS log is the #1 diagnostic tool (also see Maxim 2), so please post the log of your macro call; use the same posting method ({I} button) that you used for posting the code.

As @Astounding already said, the code as such looks good.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1565 views
  • 0 likes
  • 4 in conversation