Hi,
the values under var2 through var6 in the datalines and in the output do not match.
In the datalines suject1 var3=1 but in the output var3=2. Assuming the datalines are correct try this code:
data have;
input person_id event_id var2 var3 var4 var5 var6;
datalines;
1 1 2 3 1 3 5
1 2 6 1 2 4 1
2 3 3 1 4 2 5
run;
Proc sort data= have; by person_id event_id ; run;
proc transpose data=have out=tr_have;
by person_id event_id ;
var var2 var3 var4 var5 var6 ;
run;
proc sql;
create table wantp as
select distinct(person_id), min(col1) as minp, max(col1) as maxp
from tr_have
group by person_id;
create table wante as
select distinct(event_id),person_id, min(col1) as mine, max(col1) as maxe
from tr_have as a
group by event_id;
create table want as
select a.*,b.mine,b.maxe
from wantp as a left join wante as b
on a.person_id=b.person_id;
quit;