|
I've used multiple set ... key=... statements. I used the procedure
described on page 182 in "COMBINING AND MODIFYING SAS DATA SETS --
EXAMPLES". I can dig up some code for those who don't have the book but
haven't the time at the moment.
I hurriedly tried to combine a modify.. key=... and a set... key= and didn't
get far.
In addition to hurrying, I couldn't think of a practical example of when I'd
want to mix the two although I'm sure they exist.
data master(index=(X));
input X $ DOG $ ;
cards;
1 shephard
2 collie
3 bulldog
4 poodle
5 cat
;
run;
data trans;
input X $ ANIMAL $ TYPE $;
cards;
1 BIRD AA
3 CHIMP BB
5 HORSE AA
;
run;
data trans2;
input X $ ANIMAL $ TYPE $;
cards;
1 ELEPHANT AA
3 CHIMP BB
5 GIRAFFE AA
;
run;
990 data master;
991 set trans;
992 set master key=X;
993 select(_iorc_);
994 when (%sysrc(_sok)) ;
995
996 when (%sysrc(_dsenom)) do;
997 _error_=0;
998 DOG='';
999 end;
1000
1001 otherwise _error_=0;
1002 end;
1003
1004
1005
1006
1007 set trans2;
1008 modify master key=X;
ERROR: MEMBER lock is not available for WORK.MASTER.DATA, lock held by
conflicting use.
1009 DOG=ANIMAL;
1010 if TYPE='AA' then replace;
1011 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: The DATA statement used 0.05 seconds.
Bob Lambert
801-715-7361
> -----Original Message-----
> From: Berryhill, Timothy [SMTP:TWB2@PGE.COM]
> Sent: Tuesday, June 15, 1999 10:10 AM
> Subject: MODIFY Questions
>
> I am using MODIFY in 6.09 on MVS to update a masterfile in place using a
> transaction file. I am getting some unexpected results. It seems as if,
> once an ob has been rewritten with the REPLACE verb, subsequent attempts
> to
> read and remodify the same ob (using the MODIFY verb to read it again) are
> either failing to read it or failing to write it (it is not quite clear
> which). The MODIFY's use KEY=CHAN/UNIQUE, so I expect to be able to
> relocate an observation as often as required. Is anyone aware of odd
> rules
> regarding missing values during MODIFY/REPLACE/OUTPUT processing? I
> realize
> unsuccessful MODIFY's do not change values in the PDV, but it looks as if
> successful MODIFY's are not bringing in all fields, or successful
> REPLACE's
> are not writing missing values correctly.
>
> On a related note, during a MODIFY ... KEY=.. step, is it reasonable to
> SET
> ... KEY=...? The MODIFY and SET access different datasets--is there some
> confusion regarding the current record pointer (I am expecting a current
> record pointer for the MODIFY and a separate one for the SET)? Has anyone
> used MODIFY against more than one dataset in a single step?
>
> Neither P-222 nor P-242 (which both discuss MODIFY at length) mention
> anything odd about missing values, so I am expecting behavior similar to
> SET
> and OUTPUT.
|