Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-13-2005, 11:13 PM
Peetie Wheatstraw
Guest
 
Posts: n/a
Default Hash Object error

Hi,

Can anyone make sense of why I get/don't-get an error on
variable "area" in the following 9.1.3 log:

1027
1028 %let areas = 2;
1029 %let dvs = 8;
1030 %let cust_area = 4;
1031
1032 data cust(drop = _;
1033 _cct = 1;
1034 do area = 1 to &areas;
1035 do cust = _cct to (_cct + ceil(&cust_area * uniform(3)));
1036 array dv(_j_) dv1-dv&dvs;
1037 do over dv;
1038 if uniform(5) < .2 then dv = .;
1039 else dv = int(14 * uniform(9));
1040 end;
1041 output;
1042 _cct + 1;
1043 end;
1044 end;
1045 *put _all_;
1046 run;

NOTE: The data set WORK.CUST has 8 observations and 10 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds


1047
1048 proc print; run;

NOTE: There were 8 observations read from the data set WORK.CUST.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


1049
1050 data _null_;
1051
1052 declare hash h(dataset: "work.cust", hashexp: 6);
1053 h.defineKey('area');
1054 h.defineData(all: 'yes');
1055 h.defineDone();
1056
1057 set cust(obs=0);
1058 stop;
1059 run;

NOTE: There were 8 observations read from the data set WORK.CUST.
NOTE: There were 0 observations read from the data set WORK.CUST.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds


1060
1061 data _null_;
1062
1063 declare hash h(dataset: "work.cust", hashexp: 6);
1064 h.defineKey('area');
1065 h.defineData(all: 'yes');
1066 h.defineDone();
1067
1068 stop;
1069 run;

ERROR: Undeclared key symbol area for hash object at line 1066 column 5.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds


1070
1071 data _null_;
1072
1073 declare hash h(dataset: "work.cust", hashexp: 6);
1074 h.defineKey('area');
1075 h.defineData(all: 'yes');
1076 h.defineDone();
1077
1078 declare hiter hi('h');
1079 rc_first=hi.first();
1080 do _i = 0 by 0 while (^hi.next());
1081 dsn = 'dsn' || put(_i, 3.-L);
1082 h.output(dataset: dsn);
1083 end;
1084
1085 put _all_;
1086
1087 stop;
1088 run;

ERROR: Undeclared key symbol area for hash object at line 1076 column 5.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

Much thanks for any help with this. Please note that I am
merely toying around with the Hash Object to see what
works and what doesn't.

Peetie
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 05-14-2005, 01:23 AM
Richard A. DeVenezia
Guest
 
Posts: n/a
Default Re: Hash Object error

Peetie Wheatstraw wrote:
> 1070
> 1071 data _null_;
> 1072
> 1073 declare hash h(dataset: "work.cust", hashexp: 6);
> 1074 h.defineKey('area');
> 1075 h.defineData(all: 'yes');
> 1076 h.defineDone();
> 1077
> 1078 declare hiter hi('h');
> 1079 rc_first=hi.first();
> 1080 do _i = 0 by 0 while (^hi.next());
> 1081 dsn = 'dsn' || put(_i, 3.-L);
> 1082 h.output(dataset: dsn);
> 1083 end;
> 1084
> 1085 put _all_;
> 1086
> 1087 stop;
> 1088 run;
>
> ERROR: Undeclared key symbol area for hash object at line 1076 column
> 5. ERROR: DATA STEP Component Object failure. Aborted during the
> EXECUTION phase. NOTE: The SAS System stopped processing this step
> because of errors.
> NOTE: DATA statement used (Total process time):
> real time 0.02 seconds
> cpu time 0.03 seconds
>
> Much thanks for any help with this. Please note that I am
> merely toying around with the Hash Object to see what
> works and what doesn't.


Hi Peetie:

This came up earlier this week. The problem sounds like a candidate for the
ne'er to be published SAS FAQ ( I have not the energy to think about such a
thing )

The problem is that even though you specify all:'yes' to use each column of
table work.cust as the data items of the hash, there are no corresponding
PDV variables available to 'host' the hash data items when a method such as
FIND is run. They easiest way to 'prep' the PDV is to place this above the
hash declaration.

if 0 then set work.cust;

The if is one that will never do a set because the test, 0, is always false.
The side effect of the if set statement however is to cause the PDV to
'inherit' the columns of table work.cust. These existence of these columns
will satisfy the 'data vector configuration tests' that the hash object
performs.

--
Richard A. DeVenezia


Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BLT compilation vinayak.mdesai@gmail.com Newsgroup comp.lang.tcl 4 04-03-2009 12:09 PM
Re: dynamically assigning values to macro variabel Peter Crawford Newsgroup comp.soft-sys.sas 0 07-18-2007 09:34 PM
dynamically assigning values to macro variabel =?iso-8859-1?q?Rune_Runnest=F8?= Newsgroup comp.soft-sys.sas 1 07-18-2007 07:13 PM
Re: Hash object (was Re: Dynamically created dataset using hash Dorfman, Paul Newsgroup comp.soft-sys.sas 0 08-28-2006 06:40 AM
Hash object (was Re: Dynamically created dataset using hash object?) Scott Bass Newsgroup comp.soft-sys.sas 1 08-27-2006 10:16 PM



All times are GMT. The time now is 11:40 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.