I want to create a macro where I can very quickly subset my observations from the first 5 days of the month then merge this with another dataset by unique ID and compare results. Just wondering how I should be coding to create a macro where I can choose random observations based on the date variable being between the first say 5 days or 7days of each and every month.
Merging should be quite easy after that right? Sorry Im not very good with macros :x
Cheers & Thanks!
As has been suggested previously on this forum channel, suggest you start out first with a working SAS program to confirm the basic logic and code required (DATA, PROC steps, and within them any SAS functions needed).
Then, based on what component(s) of your code is expected to be "variable", then consider leveraging the benefits of the SAS macro facility to create an suitable process that offers desired flexibility that's needed to suit our data filtering and analysis requirements.
There are multiple approaches and SAS facilities to consider using, what with PROC SQL, PROC SORT, DATA step (using MERGE with a BY), and associated SAS functions like DAY().
Especially considering that you are not familiar with SAS macro coding (as stated in your post), it's best to define the logic/process flow, then come back to the forum for additional guidance with evolving the code-piece into a macro, as required.
this is not the first time a request involving "macro" may just be using the wrong terminology. As here when the poster should just be asking for any program solution.
The term "macro" in excel seems to refer to the only form of processing in that environment (if "formula" is just not enough).
So those new to SAS environment may think they should use the term macro to ask about any SAS programming.
(they are certainly not ready for SAS macros at such a new-entrant stage).