02-05-2017 01:37 PM
Need some help with some average. the question that i have is:
Creating new variable eg AdjustedGPA from a dataset that has GPA in the file minus the average GPA for the whole dataset. I tried the mean function by
proc means data=exam.Students;
I also tried sum
DATA students; set students1;
AveGPA = sum(GPA);
it gave the same results for the average and the gpa.
I also need to calculate the adjusted GPA for the whole dataset.
so how do i do it. i use sas for acedemics.
02-05-2017 02:41 PM
Try it as two steps:
proc summary data=exam.students;
output out=means (keep=AveGPA) mean=AveGPA;
if _n_=1 then set means;
This gets you the average GPA on every observation in EXAM.STUDENTS.
02-05-2017 02:54 PM
Perhaps there are other ways, but you could perhaps make use of a neat feature in SAS SQL, remerge statistics with original data. Try something like:
proc sql; create table want as select *, GPA - mean(GPA) as AdjustedGPA from have; quit;
02-05-2017 03:13 PM
I like your sql suggestion but i need to stick to sas studio as that is what my school wants. however, i tried the previous suggestion and i was able to get an average GPA for the whole dataset. the purpose of the average GPA was to calculate the adjusted GPA. so the adjusted gpa should be the gpa that is reported in the file minus the average gpa. i still havent figured the last part. so please help me.
02-05-2017 06:11 PM
Do you mean you need to know how to add this to the final DATA step:
AdjustedGPA = GPA - AveGPA;
Also consider an alternative:
AdjustedGPA = GPA / AveGPA;
It might be easier to work with values that are always positive instead of a mix of positive and negative ... depends on the analysis you are planning.
02-05-2017 06:17 PM
I tried this but its giving "." in all GPA, AveGPA and AdjustedGPA.
I need to have all three variables in the dataset students. and i am not sure how to work with values. i am really new at this so i am lost. i do appreciate your help and guidance.
02-05-2017 06:31 PM
This means the original construction of your data set is faulty. All the GPA values are missing. You'll have to go back to the step that created the data set in the first place.
02-05-2017 06:39 PM - edited 02-05-2017 06:42 PM
Sorry mistake. It was good until i did this step
after that step, the adjustedgpa and avegpa are showing "."
so where do you think i have gone wrong. as you suggested before it could be the negative values but i am not sure how to calculate the adjusted gpa otherwise. I also tried the GPA/AveGPA and still there are dots. so how do i calculate with values
02-05-2017 08:27 PM - edited 02-05-2017 08:27 PM
I figured the adjusted GPA. it was really traumatic but got it in the end. I thank you and the other poster for your help.