Freq's a wreck
proc freq is very useful if you want to see a quick frequency distribution of some variables on screen. But often you want to save that distribution, and use it as the basis for some calculations, or merge it with another file. For instance, you might have a file with all the candidates' item marks and you want to derive a file containing the mark distribution for all the items. To view them on screen you would do something like:
proc freq data = marks;You would think that if you did the following, you would save these results to the file 'mark_distribution':
by item;
tables mark mark_adjusted;
run;
proc freq data = marks noprint;But output is only meant to save to file certain statistics, like the mean and so on. Since you didn't specify any, freq will throw a wobble. Here's how to do what you really want:
by item;
tables mark mark_adjusted;
output out = mark_distribution;
run;
proc freq data = marks;Of course, if you want these distributions combined you will have to merge them:
by item;
tables mark / noprint out = mark_distribution;
tables mark_adjusted / noprint out = mark_adj_distribution;
run;
proc sort data = mark_distribution; by item mark; run;
proc sort data = mark_adj_distribution; by item mark; run;
data mark_distribution;
merge mark_distribution mark_adj_distribution;
by item mark;
run;
proc datasets; delete mark_adj_distribution; run;