본문 바로가기

전산Tip/SAS

(19)
[SAS] array로 missing 처리 rsubmit; data step7; set step6; array x _numeric_ ; do over x; if x =. then x = 0; end; run; endrsubmit; iPhone 에서 작성된 글입니다.
[SAS] 필드의 max length를 구하여 실제 length로 변경하여 적재 %MACRO ORA_TBL_DOWNLOAD_2(TBL); PROC SQL; CREATE TABLE COLS AS SELECT * FROM DICTIONARY.COLUMNS WHERE LIBNAME = UPCASE("ORA") AND MEMNAME = UPCASE("&TBL") ORDER BY VARNUM ; QUIT; DATA COLS2; SET COLS; IF TYPE='char'; RUN; DATA _NULL_; SET COLS2 END=EOF NOBS=TCNT; CALL SYMPUT('VARNAME'||LEFT(_N_), COMPRESS(NAME)); IF EOF THEN CALL SYMPUT('TCNT', COMPRESS(TCNT)); RUN; %PUT TCNT IS &TCNT; PROC SQL;..
[SAS] 디시전트리 룰 추출 쿼리 [오라클에 디시전트리 소스를 테이블 형태로 업로드한 후 실행] WITH V1 AS ( SELECT * FROM Z_DT_RULE_SC4_M05 /* 디시전트리 소스 테이블 */ ) SELECT MAX(CORP) AS CORP , MAX(MODEL) AS MODEL , DIV AS SEQ , MAX(NODE) AS NODE , MAX(CNT) AS CNT , MAX(Y_PER) AS Y_PER , MAX(CASE WHEN PNO=1 THEN SCRIPT2 END) ||MAX(CASE WHEN PNO=2 THEN ' '||SCRIPT2 END) ||MAX(CASE WHEN PNO=3 THEN ' '||SCRIPT2 END) ||MAX(CASE WHEN PNO=4 THEN ' '||SCRIPT2 END) ||..
[SAS] spawn 설정 (win NT) [start_objspawn.bat] C: cd "C:\Program Files\SAS\SAS 9.1" objspawn -configfile obj.cfg -nosecurity [start_spawner.bat] C: cd C:\Program Files\SAS\SASFoundation\9.2 spawner -c tcp -nosecurity
[SAS] 소스파일 text infile하기 RSUBMIT; %MACRO TXT_INFILE(P_CORP, P_MODEL, P_FILE); DATA DT_RULE_&P_CORP._&P_MODEL; CORP = "&P_CORP"; MODEL = "&P_MODEL"; INFILE "&P_FILE"; LENGTH SCRIPT $1000.; INPUT SCRIPT 1-1000 @@; RUN; %ORA_TBL_UPLOAD(WORK.DT_RULE_&P_CORP._&P_MODEL); %MEND; ENDRSUBMIT; RSUBMIT; %TXT_INFILE(SC3, M09, C:\Documents and Settings\sassrv\My Documents\My SAS Files\9.2\DT_RULE\SC3_M09.TXT); ENDRSUBMIT;
[SAS] 오라클 UPLOAD 매크로 ************************* 공통매크로 설정(SERVER) ****************************/ /***** 오라클(SVOC) 컬럼에 COMMENT 추가하기 *****/ /***** 실행 예 : %ORA_COMMENT(테이블명, 컬럼명, COMMENT명); *****/ RSUBMIT; %MACRO ORA_COMMENT(P_TBL, P_COL, P_CMT); DATA _NULL_; P_CMT2 = "&P_CMT"; CALL SYMPUT('P_CMT2', "'"||COMPRESS("&P_CMT")||"'"); RUN; PROC SQL; CONNECT TO ORACLE(USER=USERID PASSWORD='PASSWORD' PATH=SID); EXECUTE ( COMMENT..
[SAS] proc format proc format; value $relation '01' = '조부' '02' = '조모' '03' = '부' '04' = '모' '05' = '배우자(여)' '06' = '배우자(남)' '07' = '형' '08' = '제' '09' = '자' '10' = '매' '11' = '아들' '12' = '딸' '13' = '손자' '14' = '손녀' '15' = '며느리' '16' = '삼촌' '17' = '사촌' '18' = '사촌이상친척' '19' = '사위' '20' = '장인' '21' = '장모' '22' = '시아버지' '23' = '시어머니' '24' = '사업자' '25' = '본인' '99' = '기타' ; run; data test; rcode = '01'; output; rcode ..
[SAS] hash를 이용한 row 병합 data goals; input player $ when & $9.; datalines; Hill 1st 01:24 Jones 1st 09:43 Santos 1st 12:45 Santos 2nd 00:42 Santos 2nd 03:46 Jones 2nd 11:15 ; data _null_; length goals_list $ 64; if _N_ = 1 then do; declare hash h(); h.defineKey('player'); h.defineData('player', 'goals_list'); h.defineDone(); end; set goals end=done; if h.find() ^= 0 then do; goals_list = when; h.add(); end; else do; goa..

반응형