0
我需要做這個列數據的頻率分佈而不使用任何proc freq; proc sql。我只允許使用proc排序。SAS countif函數不使用proc
在Excel中,我會使用一個簡單的countif,但我不知道如何在SAS給出以上的限制。
data sample_grades;
input grades $;
datalines;
C
A
A
B
B+
A-
W
A
A-
A
A-
A
B+
A-
A
B+
B+
A-
B+
;
run;
我想出了這一點,但它停在A-
data new_dataset;
set Fall2016;
by grade;
retain grade frequency;
if grade = 'A' then frequency+1;
else if grade = 'A-' then frequency=0;
if grade = 'A-' then frequency+1;
else if grade = 'B' then frequency=0;
if grade = 'B' then frequency+1;
else if grade = 'B+' then frequency=0;
if grade = 'B+' then frequency+1;
else if grade = 'B-' then frequency=0;
if grade = 'B-' then frequency+1;
else if grade = 'C' then frequency=0;
if grade = 'C' then frequency+1;
else if grade = 'W' then frequency=0;
if grade = 'W' then frequency+1;
else frequency+0;
if last.grade then do;
frequency+0;
end;
run;
最終計數我在找一個簡單的表是這樣的: enter image description here