Help using Base SAS procedures

SAS 9.1.3 Hash where option problem

Reply
Contributor
Posts: 35

SAS 9.1.3 Hash where option problem

Hello Everybody!


The SAS code in the below or attachment will cause error in SAS 9.1.3  but it won't cause error at SAS 9.2.Is  there anybody have ever met the same kind problem before? Is there any solution?


Thanks a lot!


George


data Base;

input id $ amount;

datalines;

a  189

b  160

b  188

b  165

a  145

a  199

b 198

b  345

c  298

c 165

d 235

d 678

e 161

e 285

f 278

;

data Name;

    input id $ name $ n;

datalines;

a Jose 1

b Hose 2

c Jerry 3

d Sara 4

e Tom 5

;

data test6(drop=rc);

if 0 then set name;

if _n_ = 1 then do;

  dcl hash h(dataset: 'name (where=(n < 3))');

  h.definekey("id");

  h.definedata("id","name",'n');

  h.definedone();

end;

do until(eof);

set base end=eof;

name='';

rc=h.find();

output;

end;

run;

Attachment
Contributor
Posts: 35

SAS 9.1.3 Hash where option problem

I didn't find any discussion relate to this problem.

Respected Advisor
Posts: 3,124

SAS 9.1.3 Hash where option problem

What kind of error message?

Contributor
Posts: 35

SAS 9.1.3 Hash where option problem

ERROR: The value NAME (WHERE=(N < 3)) is not a valid SAS name.

ERROR: Hash data set load failed at line 35 column 3.

ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: There were 1 observations read from the data set WORK.BASE.

WARNING: The data set WORK.TEST6 may be incomplete. When this step was stopped there were 0

observations and 4 variables.

It should be casued by where option.

Respected Advisor
Posts: 3,124

SAS 9.1.3 Hash where option problem

Apparently data set options are not supported in hash() when SAS 9.1.3. You will have to remove the options and split it up:

data name1;

set name (where=(n<3));

run;

data test6;

if 0 then set name1;

if _n_ = 1 then do;

  dcl hash h(dataset: 'name1');

  h.definekey("id");

  h.definedata("id","name",'n');

  h.definedone();

end;

do until(eof);

set base end=eof;

name='';

rc=h.find();

output;

end;

run;

Contributor
Posts: 35

Re: SAS 9.1.3 Hash where option problem

Thank you Hai.Kuo,

Is there any hotfix for SAS9.1.3 to solute this problem ?

Respected Advisor
Posts: 3,124

Re: SAS 9.1.3 Hash where option problem

Not I am aware of. It is not a bug, it is just not supported. If you are keen on hash, you have to upgrade, the difference is day and night, before 9.2, I don't even bother with hash.

Ask a Question
Discussion stats
  • 6 replies
  • 245 views
  • 6 likes
  • 2 in conversation