BookmarkSubscribeRSS Feed
BETO
Fluorite | Level 6
Hi I have a rows of data an wanted to remove any dups the data looks like this

Machine. start 1.
A1. 11/01/15 12:34:00.
Start2
11/01/15 09:34:00
Start3.
11/01/15 09:34:00
I don't have room I didn't inlude the end time which would be also duplex ....thanks

5 REPLIES 5
Astounding
PROC Star

First step would be to read the data into a SAS data set.  Once you have done that, show us what it looks like and we'll find a way to get rid of those pesky dups.

BETO
Fluorite | Level 6

It looks some thing like this

 

machine1.       Start1.                  end1.                Machine2.             Start2.         end2.              Machine3.    Start3.                  End3

A1.            11/01/15 11:21.      11/01/15 11:38.       A1.           11/01/15 11:30 11/01/15 11:35.        A1       11/01/15 11:21. 11/01/15 11:38

 

sometimes there are up to 5 machines but normally there are 3 what I need is to remove the duplicates and keep one of the two....

 

Thanks

Ksharp
Super User

data want;

 set have;

 array m{*} machine: ;

 array s{*} Start: ;

 array e{*} end: ;

do i=1 to dim(m);

 ma=m{i};

 st=s{i};

 en=e{i};

output;

end;

drop machine: Start: end:  ;

run;

 

proc sort data=want nodupkey ; by ma st en; run;

BETO
Fluorite | Level 6
Ksharp

I ran syntax it drop my start 2 end 2 Start3 End3

It put columns I ma. St. En. ..I need the output to look like my examples minus the duplicate...the time in St an en is formated 1762078330 .... thanks for your help
Ksharp
Super User
data have;
input machine1 $ ( Start1   end1) (& anydtdtm.) Machine2 $  (Start2    end2) (& anydtdtm.) Machine3 $   (Start3  End3) (& anydtdtm.);
format _numeric_ datetime.;
cards;                 
A1  11/01/15 11:21  11/01/15 11:38  A1  11/01/15 11:30   11/01/15 11:35   A1   11/01/15 11:21  11/01/15 11:38
A1  11/01/15 11:21  11/01/15 11:38  A1  11/01/15 11:30   11/01/15 11:35   A2   11/01/15 11:21  11/01/15 11:38
;
run;

data want;
if _n_ eq  1 then do;
 length _machine $ 100 _Start _end 8;
 declare hash h();
 declare hiter hi('h');
 h.definekey('_machine','_Start','_end');
 h.definedata('_machine','_Start','_end');
 h.definedone();
end;
 set have;
 array m{*} machine: ;
 array s{*} Start: ;
 array e{*} end: ;
do i=1 to dim(m);
 _machine=m{i};_Start=s{i};_end=e{i};
 h.replace();
end;
call missing(of m{*} s{*} e{*});
i=0;
do while(hi.next()=0);
 i+1;
 m{i}=_machine;s{i}=_Start;e{i}=_end;
end;
h.clear();
drop _: i ;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1731 views
  • 0 likes
  • 3 in conversation