I wonder I can do this in Macro Loop.
For example, this is tableA
ID -- Fruit -- Count
1 Banana 1
1 Strawberry 2
1 Apple 3
1 Blueberries 4
2 Apple 1
3 Strawberry 1
3 Apple 2
I normally do like this not using SAS MACRO
proc sql;
select ID,t2.fruit AS fruit1,
t3.fruit AS fruit2,
.
.
.
from core_table t1
LEFT JOIN TableA t2 on t2.id = t1.id AND t2.count=1
LEFT JOIN TableA t3 on t3.id = t1.id AND t3.count=2
.
.
.
.
so Output is be like
ID Fruit1 Fruit2 Fruit3 Fruit4
1 Banana Strawberry Apple Blueberries
2 Apple
3 Strawberry Apple
Basically,Output will denormalise the variables. SO I am guessing I can do this task by using Do loop, I have been googling around but I can not figure out how to do.
Thanks