BookmarkSubscribeRSS Feed
halladje
Fluorite | Level 6

Hello!

 

I have a dataset of students within classrooms within schools. I am trying to create a dataset that is at the class level from the student level file (i.e. aggregate student scores - 1 variables for one classroom). 

 

I have created all my aggregated classroom variables with the following code (retaining student variables only at the class level, teacher variables which are by nature at the class level, and upper school level variables only):


proc sql;
create table teacher_is as
select x_idschool, x_class_id, t_selprog, t_female, t_sel,
mean(js_Sel) as js_sel_c, mean (j_int) as j_int_c, mean (j_ext) as j_ext_c,
mean (j_pared2) as j_pared2_c, mean (s_ageyrs) as age_c, mean(s_female) as fem_c,
TSSA11, TSSA14, TSSA19, TSSA111, TSSA113,
t_grade, t_imm, t_nonwhite,
t_com_elem6_12, t_ef,t_std_behav, t_clasS_pbs, t_sel_mean,
js_Sel_m, t_selprog_m, median, enrol, sch_lvl_Sec
from is_agg
group by x_idschool, x_class_id;
quit;

 

However, my output dataset still has a sample size at the student level. In SPSS you can aggregate up - whereby you have one observation for one class. Is there a way to do this in SAS? 

 

Thanks so much, 

Jillian 

1 REPLY 1
PaigeMiller
Diamond | Level 26

I would use PROC SUMMARY and not PROC SQL to do this, but in either case, in order to advise you properly, we would need to see a small portion of your input data set, provided according to these directions: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 462 views
  • 0 likes
  • 2 in conversation