DATA Step, Macro, Functions and more

Formats and Informats

Accepted Solution Solved
Reply
Contributor
Posts: 68
Accepted Solution

Formats and Informats

Hello

 

date.pngThe format for the variable "race_date" is MMDDYY10. and there are 10 characters in the variable - 2 for date, 2 for month, 4 for year and two forward slashes.
 
Can you please let me know why the variable is displaying a Length of 8 in Column Properties.

Accepted Solutions
Solution
‎01-23-2017 04:29 AM
Occasional Contributor
Posts: 9

Re: Formats and Informats

In SAS, Dates are stored as numeric values. Numeric values (by default) use 8 bytes in storage. 

The date values are not stored as is, but are converted in to a number by calculating the number of days that have passed from 1st Jan 1960, to the given date. This number is then stored in numeric form taking up 8 bytes by default.

 

Formats simply tell SAS how a value should be displayed. You can change the format without affecting whatever value was actually stored. For example, if you changed the format to MMDDYY5., then the dates would only display MM/YY part of the date. But that would not affect the actual value stored, so, if you went back to using the format MMDDYY10., then you would see the date how it is seen now. 

View solution in original post


All Replies
Solution
‎01-23-2017 04:29 AM
Occasional Contributor
Posts: 9

Re: Formats and Informats

In SAS, Dates are stored as numeric values. Numeric values (by default) use 8 bytes in storage. 

The date values are not stored as is, but are converted in to a number by calculating the number of days that have passed from 1st Jan 1960, to the given date. This number is then stored in numeric form taking up 8 bytes by default.

 

Formats simply tell SAS how a value should be displayed. You can change the format without affecting whatever value was actually stored. For example, if you changed the format to MMDDYY5., then the dates would only display MM/YY part of the date. But that would not affect the actual value stored, so, if you went back to using the format MMDDYY10., then you would see the date how it is seen now. 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 124 views
  • 0 likes
  • 2 in conversation