<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A question about when use hash in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607602#M176671</link>
    <description>&lt;P&gt;No problem. Then do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cm1;
    format usubjid cmseq atc atc3 ;
    if _N_=1 then do;
        dcl hash h(multidata:'Y');
        h.definekey('usubjid', 'cmseq');
        h.definedata('qnam', 'qval');
        h.definedone();

        do until(lr);
          set suppcm end=lr;
          cmseq=input(idvarval, best8.);
          rc=h.add();
        end;
    end;

    set cm;

    do while (h.do_over()=0);
       if      qnam='ATC'  then atc=qval;
       else if qnam='ATC3' then atc3=qval;
    end;

    keep usubjid cmseq atc atc3 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Nov 2019 10:53:08 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-11-27T10:53:08Z</dc:date>
    <item>
      <title>A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607586#M176666</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I have :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.SUPPCM;
  infile datalines dsd truncover;
  input USUBJID $ 1 IDVARVAL $ 3-4 QNAM $ 6-9 QVAL :$200.;
  label USUBJID="Unique Subject Identifier" IDVARVAL="Identifying Variable Value" QNAM="Qualifier Variable Name" QVAL="Data Value";
datalines;
a 1  ATC  AAA
a 1  ATC3 BBB
a 10 ATC  OLISM
a 10 ATC3 GASTRO
a 11 ATC  CSYSTEM
a 11 ATC3 SFFECTS
a 12 ATC  VARIOUS
a 13 ATC  ALISM
a 13 ATC3 DRESOPHAGERD
a 2  ATC  ANTNTS
a 2  ATC3 ANTIMES
a 3  ATC  ANTINEOPLLATING AGENTS
a 3  ATC3 OTHASTS
a 4  ATC  ANTINGENTS
a 4  ATC3 ANTIMITES
a 5  ATC  CARDEM
b 1  ATC  FF
b 1  ATC3 DDFAS
b 10 ATC  OLIFASFSM
b 10 ATC3 GASFTRO
b 11 ATC  CSYASTEM
b 11 ATC3 SFFSDECTS
b 12 ATC  VAFRIOUS
b 13 ATC  ALISM
b 13 ATC3 DRFESOPHAGERD
b 14 ATC  ALIFSM
b 14 ATC3 DRFDESOPHAGERD
b 2  ATC  ANTNSDFTS
b 2  ATC3 ANTIMES
b 3  ATC  ANTINEOPLLATING AGENTS
b 3  ATC3 OTHASDSTS
b 4  ATC  ANTIFNGENTS
b 4  ATC3 ANTIMITES
b 5  ATC  CARDSDEM
b 5  ATC3 CARDSDEM
b 6  ATC  fssdf
b 6  ATC3 FSDFD
;;;;
run;

data WORK.CM;
  infile datalines dsd truncover;
  input USUBJID $ 1 CMSEQ;
  label USUBJID="Unique Subject Identifier" CMSEQ="Sequence Number";
datalines;
a 1
a 2
a 3
a 4
a 5
a 6
a 7
a 8
a 9
a 10
a 11
a 12
a 13
b 1
b 2
b 3
b 4
b 5
b 6
b 7
b 8
b 9
b 10
b 11
b 12
b 13
b 14
b 15
b 16
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and my code is as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cm1;
if _n_=1 then do;
  dcl hash h();
  h.definekey('usubjid','cmseq');
  h.definedata('usubjid','cmseq','atc','atc3');
  h.definedone();
end;
  do until(last.idvarval);
    set suppcm;
    by usubjid idvarval;
    if qnam='ATC' then atc=qval;
    if qnam='ATC3' then atc3=qval;
  end;
  cmseq=input(idvarval,best.);
  h.add();


  set cm;
  call missing(atc,atc3);
  rc=h.find();

  keep usubjid cmseq atc atc3 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What puzzled me is that atc and atc3 are all missing when cmseq=2,3,4,5,6,7,8,9.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FSD.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34272iF6EA7B8DE31B143B/image-size/large?v=v2&amp;amp;px=999" role="button" title="FSD.png" alt="FSD.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is something wrong with my code？Please help me. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 09:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607586#M176666</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2019-11-27T09:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607588#M176668</link>
      <description>&lt;P&gt;here is how I would do it..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=suppcm out=suppcm_wide(drop=_:);
    by USUBJID IDVARVAL;
    id QNAM;
    var QVAL;
run;

data cm1;
  format usubjid cmseq atc atc3 a;
  if _n_=1 then do;
    dcl hash h();
    h.definekey('usubjid','cmseq');
    h.definedata('usubjid','cmseq','atc','atc3');
    h.definedone();

    do until(lr);
      set suppcm_wide end=lr;
      cmseq=input(idvarval, best.);
      rc=h.add();
    end;
  end;

  set cm;
  call missing(atc,atc3);
  if h.find()=0 then a=1;

  keep usubjid cmseq atc atc3 a;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 09:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607588#M176668</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-27T09:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607590#M176669</link>
      <description>Hi draycut,&lt;BR /&gt;I don't know why my last message was deleted.&lt;BR /&gt;&lt;BR /&gt;Thank you so much for your response.&lt;BR /&gt;&lt;BR /&gt;But my goal is to use hash to complete this by only one data process.&lt;BR /&gt;&lt;BR /&gt;So I don't want to use transpose before the data process.&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Nov 2019 09:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607590#M176669</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2019-11-27T09:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607602#M176671</link>
      <description>&lt;P&gt;No problem. Then do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cm1;
    format usubjid cmseq atc atc3 ;
    if _N_=1 then do;
        dcl hash h(multidata:'Y');
        h.definekey('usubjid', 'cmseq');
        h.definedata('qnam', 'qval');
        h.definedone();

        do until(lr);
          set suppcm end=lr;
          cmseq=input(idvarval, best8.);
          rc=h.add();
        end;
    end;

    set cm;

    do while (h.do_over()=0);
       if      qnam='ATC'  then atc=qval;
       else if qnam='ATC3' then atc3=qval;
    end;

    keep usubjid cmseq atc atc3 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607602#M176671</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-27T10:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607620#M176682</link>
      <description>Thanks~&lt;BR /&gt;But I run the code on my new data as above，the result look like not right.&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607620#M176682</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2019-11-27T11:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607622#M176684</link>
      <description>&lt;P&gt;What differs from the way you want it to look? Please be more specific&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607622#M176684</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-27T11:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607627#M176688</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="11f.png" style="width: 596px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34275iA03E9DF47DC7819F/image-size/large?v=v2&amp;amp;px=999" role="button" title="11f.png" alt="11f.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please see the detail as above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like only map the first record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607627#M176688</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2019-11-27T11:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607632#M176690</link>
      <description>&lt;P&gt;Just to be clear. When I run this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.SUPPCM;
  infile datalines dsd truncover;
  input USUBJID $ 1 IDVARVAL $ 3-4 QNAM $ 6-9 QVAL :$200.;
  label USUBJID="Unique Subject Identifier" IDVARVAL="Identifying Variable Value" QNAM="Qualifier Variable Name" QVAL="Data Value";
datalines;
a 1  ATC  AAA
a 1  ATC3 BBB
a 10 ATC  OLISM
a 10 ATC3 GASTRO
a 11 ATC  CSYSTEM
a 11 ATC3 SFFECTS
a 12 ATC  VARIOUS
a 13 ATC  ALISM
a 13 ATC3 DRESOPHAGERD
a 2  ATC  ANTNTS
a 2  ATC3 ANTIMES
a 3  ATC  ANTINEOPLLATING AGENTS
a 3  ATC3 OTHASTS
a 4  ATC  ANTINGENTS
a 4  ATC3 ANTIMITES
a 5  ATC  CARDEM
b 1  ATC  FF
b 1  ATC3 DDFAS
b 10 ATC  OLIFASFSM
b 10 ATC3 GASFTRO
b 11 ATC  CSYASTEM
b 11 ATC3 SFFSDECTS
b 12 ATC  VAFRIOUS
b 13 ATC  ALISM
b 13 ATC3 DRFESOPHAGERD
b 14 ATC  ALIFSM
b 14 ATC3 DRFDESOPHAGERD
b 2  ATC  ANTNSDFTS
b 2  ATC3 ANTIMES
b 3  ATC  ANTINEOPLLATING AGENTS
b 3  ATC3 OTHASDSTS
b 4  ATC  ANTIFNGENTS
b 4  ATC3 ANTIMITES
b 5  ATC  CARDSDEM
b 5  ATC3 CARDSDEM
b 6  ATC  fssdf
b 6  ATC3 FSDFD
;;;;
run;

data WORK.CM;
  infile datalines dsd truncover;
  input USUBJID $ 1 CMSEQ;
  label USUBJID="Unique Subject Identifier" CMSEQ="Sequence Number";
datalines;
a 1
a 2
a 3
a 4
a 5
a 6
a 7
a 8
a 9
a 10
a 11
a 12
a 13
b 1
b 2
b 3
b 4
b 5
b 6
b 7
b 8
b 9
b 10
b 11
b 12
b 13
b 14
b 15
b 16
;;;;
run;

data cm1;
    format usubjid cmseq atc atc3 ;
    if _N_=1 then do;
        dcl hash h(multidata:'Y');
        h.definekey('usubjid', 'cmseq');
        h.definedata('qnam', 'qval');
        h.definedone();

        do until(lr);
          set suppcm end=lr;
          cmseq=input(idvarval, best8.);
          rc=h.add();
        end;
    end;

    set cm;

    do while (h.do_over()=0);
       if      qnam='ATC'  then atc=qval;
       else if qnam='ATC3' then atc3=qval;
    end;

    keep usubjid cmseq atc atc3 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is my result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs usubjid cmseq atc                     atc3 
1   a       1     AAA                     BBB 
2   a       2     ANTNTS                  ANTIMES 
3   a       3     ANTINEOPLLATING AGENTS  OTHASTS 
4   a       4     ANTINGENTS              ANTIMITES 
5   a       5     CARDEM   
6   a       6       
7   a       7       
8   a       8       
9   a       9       
10  a       10    OLISM                   GASTRO 
11  a       11    CSYSTEM                 SFFECTS 
12  a       12    VARIOUS                   
13  a       13    ALISM                   DRESOPHAGERD 
14  b       1     FF                      DDFAS 
15  b       2     ANTNSDFTS               ANTIMES 
16  b       3     ANTINEOPLLATING AGENTS  OTHASDSTS 
17  b       4     ANTIFNGENTS             ANTIMITES 
18  b       5     CARDSDEM                CARDSDEM 
19  b       6     fssdf                   FSDFD 
20  b       7        
21  b       8        
22  b       9        
23  b       10    OLIFASFSM               GASFTRO 
24  b       11    CSYASTEM                SFFSDECTS 
25  b       12    VAFRIOUS                 
26  b       13    ALISM                   DRFESOPHAGERD 
27  b       14    ALIFSM                  DRFDESOPHAGERD 
28  b       15        
29  b       16        &lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607632#M176690</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-27T11:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607635#M176692</link>
      <description>Oh！！！Thank you！！Thank you so much！！&lt;BR /&gt;It‘s work！！ This bothered me for a long time！&lt;BR /&gt;How do you learn to use hash? Can you give some books or methods？</description>
      <pubDate>Wed, 27 Nov 2019 11:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607635#M176692</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2019-11-27T11:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607638#M176693</link>
      <description>&lt;P&gt;Anytime &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I sure do. Obviously the &lt;A href="https://documentation.sas.com/?docsetId=lecompobjref&amp;amp;docsetTarget=p00ilfw5pzcjvtn1nfya9863fozd.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SAS Hash Object Documentation&lt;/A&gt; is a good place to start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a good book, check out&amp;nbsp;&lt;A href="https://www.sas.com/store/da_dk/books/categories/examples/data-management-solutions-using-sas-hash-table-operations-a-business-intelligence-case-study/prodBK_69153_en.html" target="_self"&gt;Data Management Solutions Using SAS® Hash Table Operations: A Business Intelligence Case Study&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 11:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607638#M176693</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-27T11:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: A question about when use hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607648#M176695</link>
      <description>Got it and thanks again!</description>
      <pubDate>Wed, 27 Nov 2019 12:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-question-about-when-use-hash/m-p/607648#M176695</guid>
      <dc:creator>Lee_wan</dc:creator>
      <dc:date>2019-11-27T12:13:29Z</dc:date>
    </item>
  </channel>
</rss>

