From sasCommunity
[edit] Breaking A Data Set Into N Number Of Data Sets
/***************************/
/** Create Some Data **/
/***************************/
Proc Summary
Data = SASHELP.prdsal3 NWay ;
Class Country State ;
Output Out = Sums ( Drop = _Freq_ _Type_ ) Sum( Actual ) = Sales ;
Run ;
/********************************************/
/** Because The Hash Method Shown Below **/
/** Requires An Explicit List Of Variables **/
/** To Be Included In The OutPut Data Sets **/
/** This Macro Variable Is A Sort Cut So **/
/** That They Do Not Have To Be ard Coded. **/
/********************************************/
Proc SQL NoPrint ;
Select Quote(Strip(Name)) Into : VarNames Separated by ' , '
From Dictionary.Columns
Where LibName = 'WORK'
And MemName = 'SUMS' ;
Quit ;
Data _Null_ ;
If 0 Then Set Sums ;
DCL Hash Countrys ( Ordered: 'A' ) ;
Countrys.definekey ( 'Country' , '_N_' ) ;
Countrys.definedata ( &VarNames ) ;
Countrys.definedone () ;
Do _N_ = 1 By 1 Until ( Last.Country ) ;
Set Sums ;
By Country ;
Countrys.Add() ;
End ;
Temp = Compress( Country , '.' ) ;
Countrys.Output ( DataSet: Temp ) ;
Run ;