- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Team,
For a particular patient there might be many procedures done.But I want to eliminate the duplicates of the same procedure if any.......
patient proc_code
101 CPT
101 CPT
101 CPT
101 SPT
101 OMT
I want:
patient proc_code
101 CPT
101 SPT
101 OMT
Regards
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
one way:
data have;
input patient proc_code $;
cards;
101 CPT
101 CPT
101 CPT
101 SPT
101 OMT
;
proc sort data=have out=want nodupkey;
by patient proc_code;
run;
proc print;run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
one way:
data have;
input patient proc_code $;
cards;
101 CPT
101 CPT
101 CPT
101 SPT
101 OMT
;
proc sort data=have out=want nodupkey;
by patient proc_code;
run;
proc print;run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks so much...is there any way i can use this with out the nodupkey??
maybe retain
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't think you can do it by retain.
another way:
data want;
set have;
by patient proc_code notsorted;
if last.proc_code;
proc print;run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
What is notsorted?is it an option?
Whats the use of it?could you please explain
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Notsorted means just that: the data is not sorted. But you want first. and last. automatic variables to reflect every change in the sequence anyway, as if it was sorted. - PG
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This code still has duplicates of patient and proc_code.Do not know the reason.but they are intermingled with other data.
I think it is good for me to follow the nodupkey
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
-----yet another way:
data have;
input patient proc_code $;
cards;
101 CPT
101 CPT
101 CPT
101 SPT
101 OMT
;
run;
data _null_;
if(1=2)then set have;
declare hash prc(dataset:"have",ordered:"a");
rc=prc.defineKey("patient","proc_code");
rc=prc.defineDone();
rc=prc.output(dataset:"want");
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Joe, I have to ask, Is there a particular reason you choose to use 'if (1=2)' instead of 'if 0', since (1=2) would always be 0? Haikuo
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Aha, Hai.Kuo the observant one!
IF(0) versus IF(1=2): I'm still brainstorming for suitable answers:
(1) "Different strokes for different folks (like CARDS vs DATALINES)".
(2) "Less mystifying to FORTRAN programmers".
(3) "Better understood by SAS debutantes".
(4) "Personal signature. (if you see that on planet Mars, then you know I'm there)"
(5) "Just being a little mischievous, getting the processor to spend an extra nanosecond".
(6) "More palatable to the human Visual and Prefrontal cortices".
(7) "More mathematically appropriate".
(8) ?
(9) ?
- -
COULD THERE BE A CATCH?
See the link below:
http://www.math.toronto.edu/mathnet/falseProofs/first1eq2.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I like your answer, you made my day, Joe.:smileylaugh:
Haikuo
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
select distinct * from have ;