Thanks again Reeza, your code example helped me fix the errors mine had! It's working now, I only adapted your changes, the PROC SQL section was already correct. And thanks to you, Xia Keshan, too, your solution was definitely less complicated than mine and even lets me reuse the numbers easily since they are in a new dataset. Pretty useful. I wonder why I came up with the macro... Still...I have another question regarding my macro approach, or rather several connected ones, just for my personal interest: The thing is...I'm writing this program to be able to manually choose a variable number of years before I run the program, that's why I created the global macro variables 'startdate' and 'enddate'. The dataset with all the cases will be updated the next years, so there will be added more and more cases in the future. The program will then cut down the original complete dataset of cases to only the ones I actually want to have for calculations or counting their numbers, which works fine at the moment. As you can see, I wanted to write the counted numbers of cases into a macro variable called 'nr_obs'. How could I create a VARIABLE number of macro variables depending on the actual number of years in my time interval, whereas every macro variable ONLY contains the number of cases of ONE YEAR? So, for example, in this case, the time interval is 5 years wide: 2009, 2010, 2011, 2012, 2013. The macro 'cases_per_year' should then create 5 different macro variables, like nr_obs1 (contains #cases 2009), nr_obs2 (contains #cases 2010), ... and so on. And on top of that, how could I 'transport' these macro variables out of the macro itself, maybe into a dataset or make them global, so I can reuse them later on...because right now, they're just local macro variables, right? Phew...again, I demand a lot, but If I try to find this out on my own and look all this up, I'll spend hours and hours on it and probably still not get it to work I guess...whereas the things you told me were instantly clear to me. So I would be really happy, if you maybe could expand Reeza's working code snippet and kind of show me how to do this. And by the way, I created a sample case dataset and took a screenshot of it. Maybe this helps. Posting edited - 12/30/2014 - 2.50pm
... View more