BookmarkSubscribeRSS Feed
deleted_user
Not applicable
hi,can somebody help me?thanks!
there're many teachers working for different department,most of them will teach in more than one department.I want to count frequencies of each teacher for each year and each school,and output to data set.
sample:
department year teacher
econ 2002 Samon
econ 2003 Samon
manag 2003 Stephen
manag 2003 Sissi
Chem 2002 Sissi
Chem 2003 Samon
Math 2003 Stephen
Math 2004 Laura
Eng 2002 Laura
Eng 2003 Stephen
My program is :
Proc freq data=a;
table teacher*(department year)/out=freqteacher;
run;
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Look at the BY statement - you will need to sort your data on the BY variable list.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
data crackman;
input department $ year teacher$;
datalines;
econ 2002 Samon
econ 2003 Samon
manag 2003 Stephen
manag 2003 Sissi
Chem 2002 Sissi
Chem 2003 Samon
Math 2003 Stephen
Math 2004 Laura
Eng 2002 Laura
Eng 2003 Stephen
;
run;
proc sql;
create table crackman as select *,count(*) as count label="frequency" from crackman group by teacher,year;
quit;

this program is what you want?
you can send me meaaage by e-mail,epidatasas@gmail.com,
KevinQin
Obsidian | Level 7
Actually, I do not know exactly what is your error:
Here are sample code:

data a;
input department $ year teacher$;
datalines;
econ 2002 Samon
econ 2003 Samon
manag 2003 Stephen
manag 2003 Sissi
Chem 2002 Sissi
Chem 2003 Samon
Math 2003 Stephen
Math 2004 Laura
Eng 2002 Laura
Eng 2003 Stephen
;
run;

Proc freq data=a;
table teacher / out=freqteacher;
table teacher*department /out=freqteacher_bydepart;
table teacher*year /out=freqteacher_byyear;
table teacher*department*year /out=freqteacher_bydepart_byyear;
run;
deleted_user
Not applicable
thanks everyone,all of you are my angel! it works! i love sas!
zg

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 1761 views
  • 0 likes
  • 3 in conversation