Well, if you want to use the method with a loop you have to use a macro.
My point was you don't need a loop in the first place.
In your method, you're creating small subsets and then exporting each individually. Usually in such a process you'll also need to clean up after and remove the datasets to prevent them from interfering with future processes and just hanging around. If you have a variable that has 100's of levels this just seems more cumbersome to me.
ODS Excel does this automatically and you don't create subsets and no loops necessary, the last example provided did all of this already.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.