2014-03-31 3 views
0

저는 SAS 4GL에서 완전히 새로운 기능을 가지고 있습니다 ...SAS 기본 테이블 가져 오기

기본 키 또는 복합 기본 키의 일부인 테이블에서 추출 할 수 있습니까? 출력 데이터 세트의 한 열에 값을 병합해야합니다.

문제는 입력으로 다른 테이블을 얻을 수 있으며, 나는 그들의 정의를 모른다는 것입니다.

답변

4

인덱스가 정의되어 있으면 해당 인덱스에서 사용 된 변수를 찾을 수 있습니다. 예를 들어, 참조 :

data blah(index=(name)); 
set sashelp.class; 
run; 

proc contents data=blah out=blahconts; 
run; 

blahcontsname이 간단한 인덱스에 있음을 표시 열이 있고 1 명 인덱스 총을 가지고.

또한, 같은 this SAS documentation example에서 다음과 같이 외래 키 제약 조건을 가질 수 있습니다

출력 창에 제약 정보를 기록
proc sql; 
    create table work.mystates 
     (state  char(15), 
     population num, 
     continent char(15), 

      /* contraint specifications */ 
     constraint prim_key primary key(state), 
     constraint population check(population gt 0), 
     constraint continent check(continent in ('North America', 'Oceania')));  

    create table work.uspostal 
     (name  char(15), 
     code  char(2) not null,   /* constraint specified as */ 
              /* a column attribute   */ 

     constraint for_key foreign key(name) /* links NAME to the   */ 
        references work.mystates /* primary key in MYSTATES */ 

        on delete restrict  /* forbids deletions to STATE */ 
              /* unless there is no   */ 
              /* matching NAME value  */ 

        on update set null); /* allows updates to STATE, */ 
              /* changes matching NAME  */ 
              /* values to missing   */ 
quit; 

proc contents data=uspostal out=postalconts; 
run; 
proc sql; 
describe table constraints uspostal; 
quit; 

. 출력 데이터 세트에서 변수가 간단한 인덱스에 있음을 알 수 있습니다.

ods output IntegrityConstraints=postalICs; 
proc contents data=uspostal out=postalconts; 
run; 
ods output close; 

또는

ods output IntegrityConstraints=postalICs; 
proc sql; 
describe table constraints uspostal; 
quit; 
ods output close; 
: 당신은 데이터 세트에 대한 정보를 얻기 위해이 ODS 출력합니다 ( PROC CONTENTS 또는 DESCRIBE TABLE CONSTRAINTS를) 중 하나를 포장 할 수 있습니다