02-12-2014 10:39 AM
I have 4 observation,which having var1 as unique key,var2 can have only 2 values like A and B. How can i create two more separate variables so that one variable flag if var 2 has value 'A' and other will flag if var 2 has value 'B'. Sorry for my bad English.
02-15-2014 06:22 PM
Proc Transpose can do that, but you will need to add a step to but in the 'N's for the missing values.
data have ;
input id template @@;
1 16 1 17 3 16 4 17
proc transpose data=have out=want prefix=TempNum ;
by id ;
var dummy ;
data want ;
set want ;
array c TempNum: ;
do over c; c=coalescec(c,'N'); end;
02-15-2014 03:55 PM
if task = 16 then tempnum16 = "Y";
else tempnum16 = "N";
if task = 17 then tempnum17 = "Y";
else tempnum17 = "N";
create table want as
select distinct clm_id, (min(tempnum16)) as tempnum16, (min(tempnum17)) as tempnum17
group by clm_id;
Normally I would use max rather than min, but Y comes after N, so you use min for the summary of the responses.