2009년 11월 21일 토요일

EG설치오류 - SAS 서버가 요청한 작업을 수행할 수 없습니다.

PC EG 설치한 상태에서 Meta Server 연결후 파일부분을 열때는 전혀 문제 없고, 라이브러리 부분을 클릭하면 발생하는 Error 내용입니다.


Error
내용 : SAS 서버가 요청한 작업을 수행할 수 없습니다.

--------------------------------------------------------
'sas.iomprovider.1'
공급자는 로컬 컴퓨터에 등록할  없습니다.
------------------------------ Technical Information Follows ------------------------------

[SAS.EG.SDS.Model]
 'sas.iomprovider.1'
공급자는 로컬 컴퓨터에 등록할  없습니다.
 ----------------------------------------------------
   at SAS.EG.SDS.Model.Server.PopulateLibraries(Collection& collection)
   at SAS.EG.SDS.Model.Broker.PopulateCollection(Collection collection)
   at SAS.EG.SDS.Model.Collection.DoPopulate()
   at SAS.EG.SDS.Model.Collection.Populate()
   at SAS.EG.SDS.Views.View.DoPopulate(DisplayOperation& op)>>[System.Data]>>
>>
>> 'sas.iomprovider.1'
공급자는 로컬 컴퓨터에 등록할  없습니다.>>
>>
>> ---------------------------------------------------->>
>>
>>    at System.Data.OleDb.OleDbConnection.CreateProviderError(Int32 hr)
   at System.Data.OleDb.OleDbConnection.CreateProvider(OleDbConnectionString constr)
   at System.Data.OleDb.OleDbConnection.Open()
   at SAS.EG.SDS.Model.Server.PopulateLibraries(Collection& collection)>>>>
오류 정보가 없습니다. REGDB_E_CLASSNOTREG(0x80040154)>>>>
>>>>
>>>> ---------------------------------------------------->>>>
>>>>
>>>> 'sas.iomprovider.1'
공급자는 로컬 컴퓨터에 등록할  없습니다.

------------------------------ End of Technical Information ------------------------------

 

[조치]

oledb가 설치되지 않아 발생하는 문제로, client8cd\eguide\bundles\sasoledb setup.exe 실행하여 추가로 설치하면 해결 가능합니다.

2009년 10월 21일 수요일

불필요한 SAS work 라이브러리 삭제하기

SAS work 라이브러리는 쌔스 프로세스가 생성될 때 만들어져서 쌔스가 종료될 때 사라지는 임시 데이터 영역입니다. 그런데 프로세스가 비정상적인 상황에서 종료되어 미처 work라이브러리가 삭제되지 않는 경우가 있습니다.
오랜 시간 이 부분을 신경쓰지 않고 있다가 어느 날 문득 디스크 공간이 많이 줄어든 걸 알게 됩니다.

그럼 사용하지 않는 work디렉토리를 삭제해야겠지요.
sasv9.cfg 파일을 보면 다음과 같이 정의되어 있는 부분이 있습니다.

-work "directory명"


해당 디렉토리를 찾아보면, 다음과 같은 디렉토리들이 만들어져 있습니다.

SAS_workD81E0003B080_SAS3
SAS_work453A0001F0E2_SAS3
SAS_workE2EE0002C2FE_SAS3

바로 여기서 불필요한 디렉토리들을 삭제하면 됩니다.

그런데 현재 실행 중인 쌔스 프로세스가 있으면 어떤 것을 지워야 할 지 알기가 힘듭니다.
이런 경우 사용하기 위한 유틸리티가 있습니다.

바로 cleanwork라는 유틸리티 입니다.

사용법은 간단합니다.

cleanwork workdirectory명

이 명령을 사용하면 사용중인 work를 제외하고 나머지를 삭제할 수 있습니다.

가능한 한 사용자가 직접 지우는 것 보다 유틸리티를 사용하는 것이 안전상 좋습니다.

2009년 10월 17일 토요일

한글 label 테스트

갑자기 label을 한글로 쓰고 싶어졌습니다. 그래서 테스트를 해봤습니다.

windows XP, AIX 5에서 각각 다음 소스를 실행했습니다.
쌔스는 9.1.3 한글버전입니다.

개인적으로 쌔스 8버전에서 한글데이터 처리 때문에 고생했던 기억이 있어서 쌔스는 다국어에 약하다는 막연한 느낌이 있었습니다.

설마했는데 결과는 "잘 작동한다" 입니다.


[테스트 소스]

%macro Test_Korean_Label(label);

    %goto &label;

    %단계1:
        %put 단계1 실행;

    %단계2:
        %put 단계2 실행;

    %단계3:
        %put 단계3 실행;

    %종료:
        %put 종료처리;

%mend;


%Test_Korean_Label(단계2);

2009년 10월 16일 금요일

%SYSFUNC로 실행 가능한 함수



FunctionDescription and Syntax
ATTRCreturns the value of a character attribute for a SAS data set.
%SYSFUNC(ATTRC(data-set-id,attr-name))
ATTRNreturns the value of a numeric attribute for specified SAS data set.
%SYSFUNC(ATTRN(data-set_id,attr-name))
CEXISTverifies the existence of a SAS catalog or SAS catalog entry.
%SYSFUNC(CEXIST(entry <, 'U'>))
CLOSEcloses a SAS data set.
%SYSFUNC(CLOSE(data-set-id))
CUROBSreturns the number of the current observation.
%SYSFUNC(CUROBS(data-set-id))
DCLOSEcloses a directory.
%SYSFUNC(DCLOSE(directory-id))
DINFOreturns specified information items for a directory.
%SYSFUNC(DINFO(directory-id,info-items))
DNUMreturns the number of members in a directory.
%SYSFUNC(DNUM(directory-id))
DOPENopens a directory.
%SYSFUNC(DOPEN(fileref))
DOPTNAMEreturns a specified directory attribute.
%SYSFUNC(DOPTNAME(directory-id,nval))
DOPTNUMreturns the number of information items available for a directory.%SYSFUNC(DOPTNUM(directory-id))
DREADreturns the name of a directory member.
%SYSFUNC(DREAD(directory-id,nval))
DROPNOTEdeletes a note marker from a SAS data set or an external file.
%SYSFUNC(DROPNOTE(data-set-id|file-id,note-id))
DSNAMEreturns the data set name associated with a data set identifier.
%SYSFUNC(DSNAME(<data-set-id>))
EXISTverifies the existence of a SAS data library member.%SYSFUNC(EXIST(member-name<,member-type>))
FAPPENDappends a record to the end of an external file.
%SYSFUNC(FAPPEND(file-id<,cc>))
FCLOSEcloses an external file, directory, or directory member.
%SYSFUNC(FCLOSE(file-id))
FCOLreturns the current column position in the File Data Buffer (FDB)
%SYSFUNC(FCOL(file-id))
FDELETEdeletes an external file. %SYSFUNC(FDELETE(fileref))
FETCHreads the next nondeleted observation from a SAS data set into the Data Set Data Vector (DDV).
%SYSFUNC(FETCH(data-set-id<,'NOSET'>))
FETCHOBSreads a specified observation from a SAS data set into the DDV.%SYSFUNC(FETCHOBS(data-set-id,obs-number<,options>))
FEXISTverifies the existence of an external file associated with a fileref.%SYSFUNC(FEXIST(fileref))
FGETcopies data from the FDB. %SYSFUNC(FGET(file-id,cval<,length>))
FILEEXISTverifies the existence of an external file by its physical name.
%SYSFUNC(FILEEXIST(file-name))
FILENAMEassigns or deassigns a fileref for an external file, directory, or output device.
%SYSFUNC(FILENAME(fileref,file-name<,device<,host-options<,dir-ref>>>))
FILEREFverifies that a fileref has been assigned for the current SAS session.%SYSFUNC(FILEREF(fileref))
FINFOreturns a specified information item for a file.
%SYSFUNC(FINFO(file-id,info-item))
FNOTEidentifies the last record that was read.
%SYSFUNC(FNOTE(file-id))
FOPENopens an external file.
%SYSFUNC(FOPEN(fileref<,open-mode<,record-length<,record-format>>>))
FOPTNAMEreturns the name of an information item for an external file.
%SYSFUNC(FOPTNAME(file-id,nval))
FOPTNUMreturns the number of information items available for an external file.
%SYSFUNC(FOPTNUM(file-id))
FPOINTpositions the read pointer on the next record to be read.%SYSFUNC(FPOINT(file-id,note-id))
FPOSsets the position of the column pointer in the FDB.
%SYSFUNC(FPOS(file-id,nval))
FPUTmoves data to the FDB of an external file starting at the current column position.
%SYSFUNC(FPUT(file-id,cval))
FREADreads a record from an external file into the FDB.%SYSFUNC(FREAD(file-id))
FREWINDpositions the file pointer at the first record. %SYSFUNC(FREWIND(file-id))
FRLENreturns the size of the last record read, or the current record size for a file opened for output.
%SYSFUNC(FRLEN(file-id))
FSEPsets the token delimiters for the FGET function.
%SYSFUNC(FSEP(file-id,cval))
FWRITEwrites a record to an external file.
%SYSFUNC(FWRITE(file-id<,cc>))
GETOPTIONreturns the value of a SAS system or graphics option.%SYSFUNC(GETOPTION(option-name<,reporting-options<,...>>))
GETVARCassigns the value of a SAS data set variable to a character DATA step or macro variable.
%SYSFUNC(GETVARC(data-set-id,var-num))
GETVARNassigns the value of a SAS data set variable to a numeric DATA step or macro variable. %SYSFUNC(GETVARN(data-set-id,var-num))
LIBNAMEassigns or deassigns a libref for a SAS data library.
%SYSFUNC(LIBNAME(libref<,SAS-data-library<,engine<,options>>>))
LIBREFverifies that a libref has been assigned.
%SYSFUNC(LIBREF(libref))
MOPENopens a directory member file.
%SYSFUNC(MOPEN(directory-id,member-name<open-mode<,record-length<,record-format>>>))
NOTEreturns an observation ID for current observation of a SAS data set.
%SYSFUNC(NOTE(data-set-id))
OPENopens a SAS data file.
%SYSFUNC(OPEN(<data-file-name<,mode>>))
PATHNAMEreturns the physical name of a SAS data library or an external file.
%SYSFUNC(PATHNAME(fileref))
POINTlocates an observation identified by the NOTE function.
%SYSFUNC(POINT(data-set-id,note-id))
REWINDpositions the data set pointer to the beginning of a SAS data set.
%SYSFUNC(REWIND(data-set-id))
SPEDISreturns a number for the operation required to change an incorrect keyword in a WHERE clause to a correct keyword.
%SYSFUNC(SPEDIS(query,keyword))
SYSGETreturns the value of the specified host environment variable.
%SYSFUNC(sysget(host-variable))
SYSMSGreturns the error or warning message produced by the last function that attempted to access a data set or external file.
%SYSFUNC(SYSMSG())
SYSRCreturns the system error number or exit status of the entry most recently called.
%SYSFUNC(SYSRC())
VARFMTreturns the format assigned to a data set variable.
%SYSFUNC(VARFMT(data-set-id,var-num))
VARINFMTreturns the informat assigned to a data set variable.%SYSFUNC(VARINFMT(data-set-id,var-num))
VARLABELreturns the label assigned to a data set variable.
%SYSFUNC(VARLABEL(data-set-id,var-num))
VARLENreturns the length of a data set variable.
%SYSFUNC(VARLEN(data-set-id,var-num))
VARNAMEreturns the name of a data set variable.
%SYSFUNC(VARNAME(data-set-id,var-num))
VARNUMreturns the number of a data set variable.
%SYSFUNC(VARNUM(data-set-id,var-name))
VARTYPEreturns the data type of a data set variable.
%SYSFUNC(VARTYPE(data-set-id,var-num))

2009년 10월 13일 화요일

data step에서 macro변수 생성/사용하기

처음 쌔스를 배울때 헛갈리게 만드는 부분들 중 하나가 데이터 스텝 내에서 매크로 변수를 사용하는 것 입니다.
가끔 아래와 같이 데이터 스텝내에서 생성된 값을 매크로 변수에 할당했는데 해당 스텝내에서 다시 불러 쓰고 싶을때가 있습니다.

[예제]
%let test=5;

data _null_;
    var1 = 10;
    call symput('test', compress(var1));

    test2=&test;
    put test2=;
run;
%put [&test];

그런데 실행해 보면 test2에 5가 들어가 있습니다. 의도했던 것은 10인데 말입니다.

데이터 스텝이 실행되는 시점에 test2=&test; <-- 요부분의 매크로변수가 정해져 버려서 test2=5; 라고 들어가 버립니다.

동적으로 매크로변수를 할당해서 사용하고 싶을때는 아래와 같이 symget 함수를 사용해야 합니다.


%let test=5;

data _null_;
    var1 = 10;
    call symput('test', compress(var1));

    test2=symget('test');
    put test2=;
run;

%put [&test];

Oracle TIMESTAMP 데이터 타입 처리

SAS 9.1.3 에서 Oracle TIMESTAMP data type을 처리하려면 별도 Hox fix를 적용해야 합니다.

적용할 hot fix는 아래 E90C11, E9BB98, E9BB99 세 개 입니다.


참고로, SAS9.2에서는 Oracle TIMESTAMP data types을 정식 지원합니다.

(http://support.sas.com/documentation/cdl/en/acreldb/61890/HTML/default/a003113620.htm)


Download: E9BB80 for Windows   (File Size: 2.0M)
ATTENTION (1): Oracle customers must also download and install SAS Oracle hot fix E9OC11.
Download E9OC11
Download E9OC11 for SAS with Asian Language Support (DBCS)
ATTENTION (2): Customers running SAS Base SQL must also download and install SAS Base hot fixes E9BB98 and E9BB99.
Download E9BB98
Download E9BB98 for SAS with Asian Language Support (DBCS)
Download E9BB99
Download E9BB99 for SAS with Asian Language Support (DBCS)

SAS에서 UNIX 명령어 실행 후 결과 받기

유닉스 SAS에서 디렉토리 내 화일 목록을 읽어오는 예 입니다.

filename oscmd pipe 'ls -l';

data dirlist;
   infile oscmd truncover;
   input mode $ 1-10 nlinks 12-14 user $ 16-23
         group $25-32 size 34-40 lastmod $ 42-53
         name $ 54-253;
run;

배치작업관리나 서버 모니터링 등에 응용하여 사용할 수 있습니다.

MONOTONIC 함수

다음과 같은 요구사항이 있을 경우 monotonic() 함수를 사용할 수 있습니다.

1) 추출한 데이터에 번호를 붙이고 싶다
2) 샘플로 10개만 추출하고 싶다

data step에서 _N_나, 오라클의 ROWNUM과 유사한 기능을 원할 때 사용할 수 있습니다.
물론 완전히 똑같이 사용할 순 없습니다만 상당히 유용한 경우가 있습니다.

[예제]
proc sql;
  select monotonic() as rowno
            , *  
  from   testdata
  where monotonic() le 10;
quit;
 
결과:
 
   rowno        id         y
-----------------------------
       1         1        66
       2         2        32
       3         3        10
       4         4        24
       5         5        50
       6         6        73
       7         7        40
       8         8        45
       9         9        88
      10        10        65

COLON (:) MODIFIER vs Truncated String Comparison Operators

특정 문자열이 '04'보다 작은 값으로 시작하는 경우 추출하는 예제입니다.
데이터 스텝에서와 proc sql에서 각가 다음과 같이 구현할 수 있습니다.


먼저 테스트용 데이터를 난수를 이용해서 생성합니다.

data testdata1;
    do id = 1 to 1000;
        x = ceil (ranuni(1) * 10000);
        charx = put (x, z4.);
        output;
    end;
run;


data step에서는 다음과 같이 구현됩니다.

/* Data Step : COLON (:) MODIFIER */
data result1;
    set testdata1;
    where charx lt :'04';
run;


동일한 결과를 Proc SQL에서 얻기 위한 샘플입니다.

/* Proc SQL : Truncated String Comparison Operators */
proc sql;
    create table result2
    as
    select *
    from testdata1
    where charx ltt '04';
quit;

Library 삭제하기

● 라이브러리 내용 모두 삭제하기
  ☞ proc datasets lib=work kill nolist memtype=all; quit;
      - work 대신에 지울 라이브러리 이름을 넣습니다


● 라이브러리 데이터셋만 삭제하기
  ☞ proc datasets lib=work kill nolist memtype=data; quit;


● 내용은 지우지 않고 라이브러리 정의만 삭제하기
  ☞ libname div_allo clear;



SAS 참조 사이트

[ Search ]
● SAS 검색 (Google)

[ Reference ]
● SAS Documentation
 
● SAS Intelligence Platform

● SAS Support

● Statwith (백승민)

● SAS Notes for Instant Usages (고려대)

● SAS tutorial - generation of a sample business datawarehouse scenario

● SAS 강좌와 통계컨설팅(조인호)

● SAS Conferences Paper

● SAS BI blog

● SAS Tips

2009년 10월 2일 금요일

SAS Community

[국내]
● LRIS Consulting (이리스컨설팅)

● My SAS

[해외]
● A collaborative online community for SAS® users worldwide