BookmarkSubscribeRSS Feed
apolitical
Obsidian | Level 7
I'm sure it can be done without a loop, but when I tried the error says "The %DO statement is not valid in open code". I wouldn't mind hearing how to fix that.
Reeza
Super User

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. 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 5919 views
  • 1 like
  • 2 in conversation