MINIME
Reset variable lengths to minimize the size of a SAS dataset
If you want to use MINIME, feel free to download it here:
Download minime.sasIf you are not prompted to "Save To Disk", then right-click the link and choose "Save Link Target As..." Otherwise, you will need to save the web page to your computer. Make sure you save the
minime.sas
file as a plain text file not an htm/html file.
Disclaimer: There is no warranty on this software either expressed or implied. This program is released under the terms and conditions of GNU General Public License.
About MINIME
Programmer: Dan Blanchette (dan_blanchette@unc.edu)
The Carolina Population Center
The University of North Carolina
Chapel Hill, NC USA
Date: 22May2003
Last updated: 09Mar2009
Reset the variable lengths to minimize the size of a SAS dataset
The Carolina Population Center
The University of North Carolina
Chapel Hill, NC USA
Date: 22May2003
Last updated: 09Mar2009
Reset the variable lengths to minimize the size of a SAS dataset
%minime( variables not to minimize , variables to minimize );
Description
The MINIME SAS macro resets variable lengths of the dataset most recently created in the WORK library
to the safest minimum for all operating systems. This should reduce the size of the SAS datafile, but it could
increase it, perhaps appropriately so. This is like the Stata command
compress.
Options
NOTE: The parameters have to be specified in the order of this list.
|
Parameters
|
Explanation
|
|
(1st)
variables not to minimize |
The first string inside the parentheses can be a list of one or more variables not to minimize. In general, it is not good to minimize long integer variables like ID variables in case in a future merge the dataset being merged in has longer ID variables than the ones in the current dataset being minimized. If no variables are listed not to minimize, then the default is to minimize all variables. |
|
(2nd)
variables to minimize |
The second string inside the parentheses after the first comma can be a list of one or more variables to minimize. If no variables are listed to minimize, then the default is to minimize all variables. |
How to use the MINIME macro:
Using the MINIME SAS macro requires that you understand how to use the %include
statement and that you know how to call a SAS macro.
For example, if you have copied this file to "
The include statement makes SAS aware of the MINIME SAS macro which is in the file
%include "LOCATION AND NAME OF A FILE THAT CONTAINS SAS CODE";
For example, if you have copied this file to "
C:\SASmacros", then you
tell SAS about this macro by adding the following line to your SAS program:
%include "C:\SASmacros\minime.sas";
The include statement makes SAS aware of the MINIME SAS macro which is in the file
minime.sas.
You call the macro by adding this to your code:
%minime;
Examples
%include "C:\SASmacros\minime.sas"; ** Make SAS aware of the MINIME macro.**;
data work.new;
set work.old;
run;
** now call the MINIME SAS macro to minimize all the variables in the dataset **;
%minime;
******************************************************************
-- To see the attrib statement MINIME used to reset the variable
lengths, use the PRINTME SAS macro after MINIME has run:
******************************************************************;
%printme;
proc contents data= work.new;
run;
** or all character variables **;
data work.new;
set work.old;
run;
%minime( , _character_ ); ** notice that the first field is empty and
* that a comma separates the two fields **;
proc contents data= work.new;
run;
** or only the numeric variables except for you ID variable: **;
data work.new;
set work.old;
run;
%minime( companyid , _numeric_ );
proc contents data= work.new;
run;
** or all variables except for you ID variable: **;
data work.new;
set work.old;
run;
%minime( companyid );
proc contents data= work.new;
run;


