I’m trying pivot translation in SAS proc SQL, and I already got my desired dataset. But I’m seeking more simple program, without the duplicate program “max(case when NO = # then ### end) as ##”, or something better way. If you have a good one, please give me some advice.
data test;
input ID $ NO TIM $;
cards;
1 1 8:31
1 2 8:32
1 3 8:33
1 4 8:34
2 1 8:35
2 2 8:36
2 3 8:37
2 4 8:38
3 1 8:41
3 2 8:42
3 3 8:43
3 4 8:44
;
run;
proc sql;
create table test2 as
select ID,
max(case when NO = 1 then TIM end) as A1,
max(case when NO = 2 then TIM end) as B1,
max(case when NO = 3 then TIM end) as C1,
max(case when NO = 4 then TIM end) as D1
from test group by ID;
quit;
/*
test2 : I want this dataset
ID A1 B1 C1 D1
1 8:31 8:32 8:33 8:34
2 8:35 8:36 8:37 8:38
3 8:41 8:42 8:43 8:44
*/