<?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 cumulative numbering of type using hash in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508555#M136590</link>
    <description>&lt;P&gt;hello. i would like to ask about cumulative numbering of clinic type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've been asked about various type of cumulative calculation in this community. i'm so thankful for all your help so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, 'hash' command is very difficult to apply in new question. so, i asked one more question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to calculative type of clinic cumulatively. raw data is here....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id date clinic ;&lt;BR /&gt;cards;&lt;BR /&gt;1 20020408 12135&lt;BR /&gt;1 20020715 12135&lt;BR /&gt;1 20030124 15109&lt;BR /&gt;1 20030308 75423&lt;BR /&gt;1 20030505 75423&lt;BR /&gt;1 20030607 75423&lt;BR /&gt;1 20030815 12135&lt;BR /&gt;2 20020615 25875&lt;BR /&gt;2 20020717 25875&lt;BR /&gt;2 20020824 55415&lt;BR /&gt;2 20020907 25875&lt;BR /&gt;2 20021215 25875&lt;BR /&gt;2 20030108 25875&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i want to make this raw data like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input id date clinic type;&lt;BR /&gt;cards;&lt;BR /&gt;1 20020408 12135 1&lt;BR /&gt;1 20020715 12135 1&lt;BR /&gt;1 20030124 15109 2&lt;BR /&gt;1 20030308 75423 3&lt;BR /&gt;1 20030505 75423 3&lt;BR /&gt;1 20030607 75423 3&lt;BR /&gt;1 20030815 12135 &lt;STRONG&gt;3&lt;/STRONG&gt;&lt;BR /&gt;2 20020615 25875 1&lt;BR /&gt;2 20020717 25875 1&lt;BR /&gt;2 20020824 55415 &lt;STRONG&gt;2&lt;/STRONG&gt;&lt;BR /&gt;2 20020907 25875 2&lt;BR /&gt;2 20021215 25875 2&lt;BR /&gt;2 20030108 25875 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as you can see in 7th row, the numbering of type is still same, because clinic '12135' is not new type of clinic for 'id 1'&lt;/P&gt;&lt;P&gt;but in 10th row, 1 was added to the numbering of type, because clinic '55415' is new type of clinic for 'id 2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried this code, but the results didn't worked out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by id;&lt;BR /&gt;if _n_=1 the do;&lt;BR /&gt;declare hash h ();&lt;BR /&gt;h.definekey('clinic');&lt;BR /&gt;h.definedata('type');&lt;BR /&gt;h.definedone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if first.id then h.clear();&lt;BR /&gt;if h.find()=0 then do;&lt;BR /&gt;type=1;&lt;BR /&gt;h.replace();&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;if h.find()^=0 then do;&lt;BR /&gt;type=type+1;&lt;BR /&gt;h.replace();&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i really appreciate for all your help.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Oct 2018 01:07:01 GMT</pubDate>
    <dc:creator>km0927</dc:creator>
    <dc:date>2018-10-30T01:07:01Z</dc:date>
    <item>
      <title>cumulative numbering of type using hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508555#M136590</link>
      <description>&lt;P&gt;hello. i would like to ask about cumulative numbering of clinic type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've been asked about various type of cumulative calculation in this community. i'm so thankful for all your help so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, 'hash' command is very difficult to apply in new question. so, i asked one more question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to calculative type of clinic cumulatively. raw data is here....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id date clinic ;&lt;BR /&gt;cards;&lt;BR /&gt;1 20020408 12135&lt;BR /&gt;1 20020715 12135&lt;BR /&gt;1 20030124 15109&lt;BR /&gt;1 20030308 75423&lt;BR /&gt;1 20030505 75423&lt;BR /&gt;1 20030607 75423&lt;BR /&gt;1 20030815 12135&lt;BR /&gt;2 20020615 25875&lt;BR /&gt;2 20020717 25875&lt;BR /&gt;2 20020824 55415&lt;BR /&gt;2 20020907 25875&lt;BR /&gt;2 20021215 25875&lt;BR /&gt;2 20030108 25875&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i want to make this raw data like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input id date clinic type;&lt;BR /&gt;cards;&lt;BR /&gt;1 20020408 12135 1&lt;BR /&gt;1 20020715 12135 1&lt;BR /&gt;1 20030124 15109 2&lt;BR /&gt;1 20030308 75423 3&lt;BR /&gt;1 20030505 75423 3&lt;BR /&gt;1 20030607 75423 3&lt;BR /&gt;1 20030815 12135 &lt;STRONG&gt;3&lt;/STRONG&gt;&lt;BR /&gt;2 20020615 25875 1&lt;BR /&gt;2 20020717 25875 1&lt;BR /&gt;2 20020824 55415 &lt;STRONG&gt;2&lt;/STRONG&gt;&lt;BR /&gt;2 20020907 25875 2&lt;BR /&gt;2 20021215 25875 2&lt;BR /&gt;2 20030108 25875 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as you can see in 7th row, the numbering of type is still same, because clinic '12135' is not new type of clinic for 'id 1'&lt;/P&gt;&lt;P&gt;but in 10th row, 1 was added to the numbering of type, because clinic '55415' is new type of clinic for 'id 2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried this code, but the results didn't worked out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by id;&lt;BR /&gt;if _n_=1 the do;&lt;BR /&gt;declare hash h ();&lt;BR /&gt;h.definekey('clinic');&lt;BR /&gt;h.definedata('type');&lt;BR /&gt;h.definedone();&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if first.id then h.clear();&lt;BR /&gt;if h.find()=0 then do;&lt;BR /&gt;type=1;&lt;BR /&gt;h.replace();&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;if h.find()^=0 then do;&lt;BR /&gt;type=type+1;&lt;BR /&gt;h.replace();&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i really appreciate for all your help.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 01:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508555#M136590</guid>
      <dc:creator>km0927</dc:creator>
      <dc:date>2018-10-30T01:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative numbering of type using hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508561#M136592</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data WANT;
  length LIST $32000;
  retain LIST ;
  drop LIST;
  set HAVE; 
  by ID;
  if first.ID then do;
    LIST=cat(CLINIC);
    TYPE=1;
  end;
  else if ^findw(LIST,catt(CLINIC)) then do;
    TYPE+1;
    LIST=catx(' ',LIST,CLINIC);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hash tables are not the universal answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;id&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;clinic&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;TYPE&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20020408&lt;/TD&gt;
&lt;TD class="r data"&gt;12135&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20020715&lt;/TD&gt;
&lt;TD class="r data"&gt;12135&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20030124&lt;/TD&gt;
&lt;TD class="r data"&gt;15109&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20030308&lt;/TD&gt;
&lt;TD class="r data"&gt;75423&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20030505&lt;/TD&gt;
&lt;TD class="r data"&gt;75423&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20030607&lt;/TD&gt;
&lt;TD class="r data"&gt;75423&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;20030815&lt;/TD&gt;
&lt;TD class="r data"&gt;12135&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20020615&lt;/TD&gt;
&lt;TD class="r data"&gt;25875&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20020717&lt;/TD&gt;
&lt;TD class="r data"&gt;25875&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20020824&lt;/TD&gt;
&lt;TD class="r data"&gt;55415&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20020907&lt;/TD&gt;
&lt;TD class="r data"&gt;25875&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20021215&lt;/TD&gt;
&lt;TD class="r data"&gt;25875&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;20030108&lt;/TD&gt;
&lt;TD class="r data"&gt;25875&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Oct 2018 01:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508561#M136592</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-10-30T01:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: cumulative numbering of type using hash</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508566#M136596</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input id date :yymmdd10. clinic ;
format date yymmdd10.;
cards;
1 20020408 12135
1 20020715 12135
1 20030124 15109
1 20030308 75423
1 20030505 75423
1 20030607 75423
1 20030815 12135
2 20020615 25875
2 20020717 25875
2 20020824 55415
2 20020907 25875
2 20021215 25875
2 20030108 25875
;

data want;
if 0 then set have;
array t(999) _temporary_;
call missing(of t(*),type);
do until(last.id);
set have;
by id ;
if clinic not in t then do;
type+1;
t(type)=clinic;
end;
output;
end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 03:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cumulative-numbering-of-type-using-hash/m-p/508566#M136596</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-30T03:23:03Z</dc:date>
    </item>
  </channel>
</rss>

