Editor's Note: Thanks to Daniel for pointing us to using a hash object as the solution. The paper by Paul Dorfman that Daniel points to contains an example of how to efficiently output to multiple data sets. Look for the section entiled Splitting a SAS File Dynamically using the .OUTPUT() Method. Example 9 shows how to use the .OUTPUT() method to dynamically output to multiple data sets. If you are not familar with hash objects in SAS, example 8 in this paper shows a non-hash method that uses PROC SQL to dynamically output to multiple data sets.
Hi.
You cannot mix macro code generated at compile-time with code evaluated at run-time.
Their is actually a workaround that I'm seeing, and that I have used in the past with success. Because of memory limitations, the data should be pre-ordered by the splitter variable (market_id).
The idea is to load into a hash object each segment (market_id) while reading the dataset and whenever reaching the next segment, output the hash to a dataset (output method), empty it, and then do the same for the next segment, until the entire dataset is processed.
The output method of the hash object allows to specify an expression for the dataset naming, so you could easily suffix some number to the dataset name.
Be aware that a hash object is entirely stored in memory, so you should be reasonable about the amount of data you store in it. This explains why you should do it by segments, instead of dealing with the whole customer records.
Check the online doc about the hash object:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a003143739.htm
The output method:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002588845.htm
And don't forget to read the excellent Paul Dorfman's paper, with particular attention for the 'SPLITTING A SAS FILE DYNAMICALLY USING THE .OUTPUT() METHOD' section:
http://www2.sas.com/proceedings/sugi30/236-30.pdf
Cheers from Portugal.
Daniel Santos @ www.cgd.pt
Editor's Note: Thanks to Daniel for pointing us to using a hash object as the solution. The paper by Paul Dorfman that Daniel points to contains an example of how to efficiently output to multiple data sets. Look for the section entiled Splitting a SAS File Dynamically using the .OUTPUT() Method. Example 9 shows how to use the .OUTPUT() method to dynamically output to multiple data sets. If you are not familar with hash objects in SAS, example 8 in this paper shows a non-hash method that uses PROC SQL to dynamically output to multiple data sets.
Hi.
You cannot mix macro code generated at compile-time with code evaluated at run-time.
Their is actually a workaround that I'm seeing, and that I have used in the past with success. Because of memory limitations, the data should be pre-ordered by the splitter variable (market_id).
The idea is to load into a hash object each segment (market_id) while reading the dataset and whenever reaching the next segment, output the hash to a dataset (output method), empty it, and then do the same for the next segment, until the entire dataset is processed.
The output method of the hash object allows to specify an expression for the dataset naming, so you could easily suffix some number to the dataset name.
Be aware that a hash object is entirely stored in memory, so you should be reasonable about the amount of data you store in it. This explains why you should do it by segments, instead of dealing with the whole customer records.
Check the online doc about the hash object:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a003143739.htm
The output method:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002588845.htm
And don't forget to read the excellent Paul Dorfman's paper, with particular attention for the 'SPLITTING A SAS FILE DYNAMICALLY USING THE .OUTPUT() METHOD' section:
http://www2.sas.com/proceedings/sugi30/236-30.pdf
Cheers from Portugal.
Daniel Santos @ www.cgd.pt
Thank you very much. This is very helpful. But I do not quite understand. Would you please explain it to me for each part of your code? Thank you again
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.