BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
johngds
Fluorite | Level 6

In Proc Summary, is there any way to set the length of variables in the output out statement?  I'm trying to avoid having to write a separate data step to set the variable lengths.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @johngds,

 

You can use the KEEPLEN option of the OUTPUT statement of PROC SUMMARY to let the statistics inherit the lengths of the analysis variables. If this is not applicable to your analysis dataset (because the variables in question have full length there), you can apply it to a DATA step view quickly created from the dataset using an appropriate LENGTH statement. (Edit: You may want to set the VARLENCHK= system option to NOWARN in this case.)

View solution in original post

7 REPLIES 7
johngds
Fluorite | Level 6

Setting variable lengths will enable me to cut the size of the file down from 4.5 GB to about 2.5 GB.  I'll still be able to maintain precision.


@Kurt_Bremser wrote:

What do you want to gain by it? It is best to let the numeric variables keep the default maximum length of 8 (because of precision).


 

Tom
Super User Tom
Super User

@johngds wrote:

Setting variable lengths will enable me to cut the size of the file down from 4.5 GB to about 2.5 GB.  I'll still be able to maintain precision.


@Kurt_Bremser wrote:

What do you want to gain by it? It is best to let the numeric variables keep the default maximum length of 8 (because of precision).


 


Is that with or without compression?

FreelanceReinh
Jade | Level 19

Hi @johngds,

 

You can use the KEEPLEN option of the OUTPUT statement of PROC SUMMARY to let the statistics inherit the lengths of the analysis variables. If this is not applicable to your analysis dataset (because the variables in question have full length there), you can apply it to a DATA step view quickly created from the dataset using an appropriate LENGTH statement. (Edit: You may want to set the VARLENCHK= system option to NOWARN in this case.)

johngds
Fluorite | Level 6

Thanks to all who responded.  I was not aware of the KEEPLEN option for the OUTPUT OUT= statement.  Clean and easy, and it saves an additional data step.  The variable I am limiting the length to 4 is an integer and takes a value between 0 and 20,000.  

Tom
Super User Tom
Super User

@johngds wrote:

In Proc Summary, is there any way to set the length of variables in the output out statement?  I'm trying to avoid having to write a separate data step to set the variable lengths.


Which variables?  What statistics are you generating?  It might make sense to truncate the storage of integer values, but the mean, standard deviation and variance of integer is going to be a floating point value.  Those variables you won't want to truncate the storage.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 945 views
  • 6 likes
  • 4 in conversation