Hi Xia,
Nice program! I didn't get it to work but I wasn't sure is if I my SAS version is too old (9.1.3) or if &colon is a macro variable that I had to declare somewhere with a %let statement.
I will give it another try with SAS 9.4 which I am so grateful to get shortly. I'll start on 9.4 to leverage hpsplit, gampl, and logistic procedures for our predictive modeling. With the extra revenue we'll buy a full license of Enterprise Miner next year.
I call myself a SAS alumni. Part of SAS family once, means SAS family always.
Thanks again! Looking forward to trying your code on SAS 9.4.
Keeping a copy of the log here for my records...
1
2 data have(rename=(old=from contract=to));
3 contract='1';old='';output;
4 contract='2';old='1';output;
5 contract='x';old='';output;
6 contract='a';old='';output;
7 contract='3';old='2';output;
8 contract='y';old='';output;
9 contract='b';old='a';output;
10 contract='4';old='3';output;
11 contract='z';old='';output;
12 contract='5';old='4';output;
13 contract='c';old='b';output;
14 contract='d';old='c';output;
15 run;
NOTE: The data set WORK.HAVE has 12 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
16
17
18
19 data full;
20 set have end=last;
21 if _n_ eq 1 then do;
22 declare hash h();
23 h.definekey('node');
24 h.definedata('node');
25 h.definedone();
26 end;
27 output;
28 node=from; h.replace();
29 from=to; to=node;
30 output;
31 node=from; h.replace();
32 if last then h.output(dataset:'node(where=(node is not missing))');
33 drop node;
34 run;
ERROR: Invalid data set name at line 32 column 16.
ERROR: An error has occurred during instance method OM_OUTPUT(505) of "DATASTEP.HASH".
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 12 observations read from the data set WORK.HAVE.
WARNING: The data set WORK.FULL may be incomplete. When this step was stopped there were 24
observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
35
36
37 data want(keep=node household);
38 declare hash ha(ordered:'a');
39 declare hiter hi('ha');
40 ha.definekey('count');
41 ha.definedata('last');
42 ha.definedone();
43 declare hash _ha(hashexp: 20);
44 _ha.definekey('key');
45 _ha.definedone();
46
47 if 0 then set full;
48 declare hash from_to(dataset:'full(where=(from is not missing and to is not
48 ! missing))',hashexp:20,multidata&colon:'y');
-
22
76
WARNING: Apparent symbolic reference COLON not resolved.
ERROR 22-322: Syntax error, expecting one of the following: <, <=, =, >, >=, EQ, GE, GT, LE, LT,
NE, NG, NL, ^=, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
49 from_to.definekey('from');
50 from_to.definedata('to');
51 from_to.definedone();
52
53 if 0 then set node;
ERROR: File WORK.NODE.DATA does not exist.
54 declare hash no(dataset:'node');
55 declare hiter hi_no('no');
56 no.definekey('node');
57 no.definedata('node');
58 no.definedone();
59
60
61 do while(hi_no.next()=0);
62 household+1; output;
63 count=1;
64 key=node;_ha.add();
65 last=node;ha.add();
66 rc=hi.first();
67 do while(rc=0);
68 from=last;rx=from_to.find();
69 do while(rx=0);
70 key=to;ry=_ha.check();
71 if ry ne 0 then do;
72 node=to;output;rr=no.remove(key:node);
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
NOTE: The SAS System stopped processing this step because of errors.
73 key=to;_ha.add();
74 count+1;
75 last=to;ha.add();
76 end;
77 rx=from_to.find_next();
-----------------
558
ERROR 558-185: Reference find_next is not a member of object from_to.
78 end;
79 rc=hi.next();
80 end;
81 ha.clear();_ha.clear();
82 end;
83 stop;
84 run;
... View more