If you don't want to type 'Local' and 'Central' by hand,you could try this SQL code.
data have;
infile cards expandtabs truncover;
input SUBJID :$40. SOURCE :$40. LBCAT &$40. LBTESTCD :$40. RANGE :$40. UNITS :$40.;
cards;
001-001-001 Central Serum Chemistry ALB 3.62-5.21 g/dL
001-001-001 Central Serum Chemistry ALP 33.0-111.0 IU/L
001-001-001 Local Serum Chemistry ALP 33.0-111.0 IU/L
001-001-001 Local Serum Chemistry ALT 10.0-39.0 IU/L
;
proc sql;
create table want as
select SUBJID,LBTESTCD,SOURCE,max(LBCAT) as LBCAT,max(RANGE) as RANGE,max(UNITS) as UNITS from
(
select a.*,b.LBCAT,b.RANGE,b.UNITS from
(select * from
(select distinct SUBJID,LBTESTCD from have),(select distinct SOURCE from have)) as a
natural left join
(select * from have) as b
)
group by SUBJID,LBTESTCD
order by SUBJID,LBTESTCD;
quit;
... View more