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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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