BookmarkSubscribeRSS Feed

[결측항목] ZERO(결측값) 값에 해당하는 항목(범주) 출력하기

Started ‎06-15-2020 by
Modified ‎06-15-2020 by
Views 97

* [결측항목] ZERO(결측값) 값에 해당하는 항목(범주) 출력하기;

data BACK;

  input gender eth count;

datalines;

1 1 12

1 2 12

1 3 21

2 1 2

2 3 43

;

run;

 

* completetypes 옵션 : CLASS 항목의 값 출력; 

 

proc summary data = BACK completetypes nway;

     class gender eth;

     var count;

     output out=BACK1 sum=;

run;

 

proc means data = BACK completetypes;

     class gender eth;

     var   count;

run;

 

 

* 출처 : http://studysas.blogspot.kr/2009/10/dummy-dataset-or-sas-options-which-is.html;

data demo ;

input siteid $ sex $ race $ age ;

cards;

SITE1 M White 23

SITE1 F White 43

SITE1 M White 34

SITE2 M Black 21

SITE2 M White 56

SITE2 F Black 33

;

run;

 

proc sort data=demo;

     by siteid; 

run;

 

 

*Without any options in proc freq;

proc freq data=demo noprint;

     table siteid*race /out=nooptions (drop=percent);

run;

 

 

*With Sparse option in proc freq;

proc freq data=demo noprint;

     table siteid*race /sparse out=_sparse (drop=percent);

run;

 

 

 

*With Completetypes and preloadfmt options in proc means;

proc format;

     VALUE $RACEF 'Asian'='Asian'

                  'Black'='Black'

                  'White'='White';

run;

 

data demo;

 set demo;

     format race $racef.;

run;

 

* completetypes 옵션 : CLASS 항목의 값 출력;

proc means data=demo completetypes noprint nway;

     class siteid race;

     output out =race1(where=(_stat_='N')rename=(_freq_=count) keep=siteid race _freq_ _stat_);

run;

 

* preloadfmt 옵션 : 사전에 정의된 FORMAT 값 기준으로 항목 출력;

proc means data=demo completetypes noprint nway;

     class siteid race/preloadfmt;

     output out =race2(where=(_stat_='N')rename=(_freq_=count) keep=siteid race _freq_ _stat_);

run;

Version history
Last update:
‎06-15-2020 01:57 AM
Updated by:
Contributors

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Article Labels
Article Tags