Help using Base SAS procedures

proc freq doesn't work?

Reply
N/A
Posts: 0

proc freq doesn't work?

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;
Super Contributor
Super Contributor
Posts: 3,174

Re: proc freq doesn't work?

Posted in reply to deleted_user
Look at the BY statement - you will need to sort your data on the BY variable list.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: proc freq doesn't work?

Posted in reply to deleted_user
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,
Contributor
Posts: 43

Re: proc freq doesn't work?

Posted in reply to deleted_user
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;
N/A
Posts: 0

Re: proc freq doesn't work?

Posted in reply to deleted_user
thanks everyone,all of you are my angel! it works! i love sas!
zg
Ask a Question
Discussion stats
  • 4 replies
  • 156 views
  • 0 likes
  • 3 in conversation