Calcite | Level 5

Hi all, calculating average of observations and create a new variable.

Data..
Dataset xyz;
Input ID\$ month checking expense;
Data lines;
X 2020/9 300 100
X. 2020/10 400 .
X 2020/11 . 60
Y 2020/9 400 .
Y 2020/10 200 50
Z 2020/19 . .
;
Run;

Result should be like this..
ID Monthsnum Average_ check averageexlense
X 3 350 80
Y 2 300 50
Z 1 . .

Any help would be greatly appreciated. I am beginner to sas programming. Proc sql is not allowed to use.
Thank you!!!
1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

Re: Hi all, calculating average of observations and create a new variable.

I believe the usual reply when someone asks for help with homework is: please give it a try first, on your own, and if you get stuck, please come back and show us the code you have created, and we will be happy to help.

--
Paige Miller
6 REPLIES 6
Barite | Level 11

Re: Hi all, calculating average of observations and create a new variable.

Proc SQL is not allowed? So this is homework?
Calcite | Level 5

Re: Hi all, calculating average of observations and create a new variable.

Yes, this is part of homework:)
Diamond | Level 26

Re: Hi all, calculating average of observations and create a new variable.

I believe the usual reply when someone asks for help with homework is: please give it a try first, on your own, and if you get stuck, please come back and show us the code you have created, and we will be happy to help.

--
Paige Miller
Calcite | Level 5

Re: Hi all, calculating average of observations and create a new variable.

Thank you!
I tried but couldn’t get it.. took help from friend and got it.. thank you for replying:))
Super User

Re: Hi all, calculating average of observations and create a new variable.

So your course has likely either taught you one of two methods - using a data step to calculate averages or proc means/summary/univariate. Which topic has been covered so far? Then google that term plus summary to find many, many examples and questions of this nature.

@Mandy5 wrote:
Data..
Dataset xyz;
Input ID\$ month checking expense;
Data lines;
X 2020/9 300 100
X. 2020/10 400 .
X 2020/11 . 60
Y 2020/9 400 .
Y 2020/10 200 50
Z 2020/19 . .
;
Run;

Result should be like this..
ID Monthsnum Average_ check averageexlense
X 3 350 80
Y 2 300 50
Z 1 . .

Any help would be greatly appreciated. I am beginner to sas programming. Proc sql is not allowed to use.
Thank you!!!

Calcite | Level 5

Re: Hi all, calculating average of observations and create a new variable.

Yes, we have learned using proc means and summary.. haven’t learned about sql yet. Thank you!
Discussion stats
• 6 replies
• 565 views
• 0 likes
• 4 in conversation