다음 코드가 있습니다.
data work.customBins;
retain fmtname 'bins' type 'n';
do binStart=-2.5 to 2.45 by 0.05;
binEnd=binStart+0.05;
difference=cat(binStart," to ",binEnd);
output;
end;
run;
proc format library=work cntlin=work.customBins; run;
proc freq data=work.myData;
table variable /missing;
format variable bins.;
run;
이 코드는 제대로 작동합니다. 내 유일한 문제는 예를 들어 -1.45에서 -1.40까지 값이없는 경우 proc freq가 무시한다는 것입니다. 예를 들어 값이없는 빈에 이전 빈의 누적 빈도를 표시하고 싶습니다.
-1.50 ~ -.145 누적 Freq = 2 %
-.1.45 ~ -1.4에는 값이 없지만 이에 대한 누적 Freq는 2 % 여야합니다.
나는 또한 이것을 시도했다
data work.combined;
set work.myData (in=a) work.customBins (in=b)
if a then cont=1;
if b then cont=0;
run;
proc freq data=work.combined;
table variable /missing;
format variable bins.;
weight cont/zeros;
run;
하지만 이것도 작동하지 않습니다
myData에는 -2.45에서 2.45 범위의 10 진수 인 변수 라는 단일 변수 만 포함됩니다.
다음은 작동하는 변형입니다.
data work.customBins;
do binStart=-2.5 to 2.45 by 0.05;
binEnd=binStart+0.05;
difference=cat(binStart," to ",binEnd);
output;
end;
run;
proc sql;
create table want as
select difference, count(variable) as count
from customBins left join mydata
on binStart < variable <= binEnd
group by difference
order by binStart;
quit;
proc freq data=want order=data;
tables difference;
weight count / zeros;
run;
첫 번째 변종에 대해. PROC FORMAT이 예상대로 작동합니까? CNTLIN 옵션에서 사용되는 데이터 세트는 자발적으로 명명 된 변수가 아닌 START, END 및 LABEL 변수를 가져야합니다. 어쨌든 PROC FREQ는 mydata 데이터 세트에있는 값만 사용하기 때문에 작동하지 않습니다. 형식에 정의한 다른 레이블 수는 중요하지 않습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다