BookmarkSubscribeRSS Feed

[HASH Object] ADD Method 예제

Started ‎06-12-2020 by
Modified ‎06-12-2020 by
Views 137

* HASH 오브젝트에 지정한 키와 연관된 데이터를 추가한다.; 

 

* 출처 : http://support.sas.com/documentation/cdl/en/lecompobjref/67221/HTML/default/viewer.htm#p0rm2a9oz8nz8...

 

 

data _null_;

   length k $8;

   length d $12;

   /* HASH 오브젝트, Key, 데이터 변수 이름을 선언한다. */

   if _N_ = 1 then do;

      declare hash h();

      rc = h.defineKey('k');

      rc = h.defineData('d');

      rc = h.defineDone();

   end;

   /* 상수 키와 데이터 값을 정의한다. */

   k = 'Joyce';

   d = 'Ulysses';

   /* HASH 오브젝트에 키와 데이터 값을 추가한다. */

   rc = h.add();

   h.output(dataset:'work.BACK1');

run;

 

* 동일한 예제;

data _null_;

   length k $8;

   length d $12;

   /* HASH 오브젝트, Key, 데이터 변수 이름을 선언한다. */

   if _N_ = 1 then do;

      declare hash h();

      rc = h.defineKey('k');

      rc = h.defineData('d');

      rc = h.defineDone();

      /* 로그에 변수가 초기화 되지 않았다는 메시지 출력을 방지한다. */

      call missing(k, d);

   end;

   /* HASH 오브젝트에 키와 데이터 값을 추가한다. */

   rc = h.add(key: 'Joyce', data: 'Ulysses');

   h.output(dataset:'work.BACK2');

run; 

Version history
Last update:
‎06-12-2020 05:38 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