02-06-2014 11:39 AM
I coded a macro loop to get a value size for each month(loop), and then want to merge all size for every month into one dataset, but I have difficulty to achieve this purpose. Let me illustrate my attempt.For each loop I will get one dataset containing firmid and size, but for each loop the firmid may be different (most of them are overlapped). For instance, month 1 would be like
month 2 would be something like
What I want to acheive is something like
firmid size(m1) size(m2)
1 100 120
2 150 140
4 . 100
5 130 .
Please help. Thanks.
02-06-2014 12:01 PM
Yes, ou could merge or SQL full join those results.
One way to do it dynamically is that in your loop (depending on the logic there...?) is to build som kind of dynamic SAS-code, which you execute in some point, i.e. using call execute.
Do you have the same data source for each loop? If so, what is the logic for creating size? Perhaps there is an easier way to solve the whole problem...
02-06-2014 12:31 PM
Since you're asking about a basic merge, I prefer to skip references to macro language and skip trying to automate the process. Here's a simple solution for two data sets. Assuming they are already sorted by FIRMID:
merge month1 (rename=(size=size_m1))
It should be easy enough to extend that to more than 2 data sets.