03-20-2013 12:12 PM
I've below sample data after proc transpose,
I want to extract first unique record on col1 and first unique record row position should not change after sorting. I need below output
03-20-2013 01:47 PM
proc summary data=have nway;
output out=want (keep=col1 position) min=;
proc sort data=want;
I would guess that SQL can do this, but my SQL syntax is suspect:
proc sql noprint;
create table want as select col1, min(position) as position from have group by col1 order by position;
03-21-2013 05:39 AM
You could also use hash tables to collect all unique elements.
In your sample data the position variable seems nicely sorted. Therefore Paige Millers' approach makes perfectly sense. If in reality that sequence is not guaranteed, you could initially add an additional variable with SequenceNumber = _N_; Then the selection as Paige is suggesting and finally sorting by SequenceNumber and dropping that variable again.