You don't need to. This program will create a new data set with zero observations, but using all variable definitions from the old data set (including lengths):
data new_dataset; stop; set old_dataset; run;
If you need a printed version of the data set structure, use PROC CONTENTS.
Yes- I want to do that for both numeric and character variables. Some of the variables have greater length than maximum length. Using COMPRESS option in the dataset can reduce the size but do not change the variable length which creates an inflated dataset when transformed to other formats.
You can use my attached macro (etl_shrinkMyData.sas) It does exactly what you are looking for.
%include "etl_shrinkmydata.sas"; %etl_shrinkMyData(p_inDsName=SASHELP.PRDSALE , p_outDsName=WORK.shrunk, p_noCompress=);
Hope this helps
That's most likely because your original data set was compressed while the newly shrunk data set has shorter record length.
You can run Proc Content against both data sets and compare the results.
If you compressed the shrunk data set, it will probably end up same size as the original if not smaller
Yes- that worked. After compressing the size is smaller than the original dataset. Is there any way to include the compress option in the macro so that it doesn't require an additional data step?
I didn't look at the source code of the macro, since it was shared as an attached instead of in the body of the message, but from the sample call you should be able to just add the COMPRESS= option to the output dataset name.
%etl_shrinkMyData (p_inDsName=SASHELP.PRDSALE ,p_outDsName=WORK.shrunk(compress=yes) ,p_noCompress= );
Or set the system option COMPRESS before calling the macro.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.