2010년 4월 6일 화요일

[PROC FREQ] OneWayFreqs output data set 생성하기

기본으로 제공되는 결과 양식을 조금 수정하여 보기 좋게 변경하는 예제입니다.


ods listing close;
ods output OneWayFreqs=outfreq;                                                  
                                                                                  
proc freq data=sashelp.class;                                                    
   tables age sex;                                                                
run;                                                                              
                                                                                  
ods output close;                                                                
ods listing;                                                                      
                                                                                  
proc print data=outfreq label;                                                    
run;                                                                              
                                                                                  
/* 테이블 양식 정리 */    
data allfreq;                                                                    
   retain table column_value;                                                    
   set outfreq;                                                                  
   keep table column_value frequency percent cumfrequency cumpercent;  

   table=scan(table,1,' ');  

   column_value=trim(left(vvaluex(table)));                                      
   label table='Table'                                                            
         column_value='Column_Value';                                            
run;                                                                              
                                                                                  
proc print data=allfreq label;                                                    
run;

2010년 4월 4일 일요일

데이터 셋 찾기

데이터셋 이름을 파라메터로 입력하면 어떤 라이브러리에 있는지 찾아주는 매크로 입니다.
 
%macro findDataSet(dsname);

    proc sql noprint;
        select  libname into :lib separated by ','
        from    sashelp.vmember
        where   memname=upcase("& dsname") and memtype='DATA'
        ;
    quit;
    %put Data Set [& dsname]은 [&lib] Library에 있습니다;

%mend findDataSet;

%findDataSet(adomsg);