<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Data format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Data-format/m-p/823944#M35100</link>
    <description>&lt;P&gt;SAS only has two types of variables, floating point numbers and fixed length character strings.&lt;/P&gt;
&lt;P&gt;Which type is the source variable?&amp;nbsp; What type do you want to create?&lt;/P&gt;
&lt;P&gt;Note that SAS stores date values as numbers, the number of days since 1960.&lt;/P&gt;
&lt;P&gt;So to convert the string '19431010' to a date use the INPUT() function with the YYMMDD8. informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;real_date = input(date,yymmdd8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To convert the number 19,431,010 to date first convert it to a string using the PUT() function and the Z8. format.&amp;nbsp; Then use the same method as above to convert string to a date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;real_date = input(put(date,z8.),yymmdd8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have a date value you can then use any date type format with it you want so that the number of days prints as a string that humans can understand.&amp;nbsp; Do make it print like MM/DD/YYYY use the MMDDYY10. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format real_date mmddyy10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to create a character variable instead then use the PUT() function to convert the date value to a string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_string=put(real_date,mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Do not display dates in either MDY or DMY order as either choice will confuse half of your audience.&amp;nbsp; Better to use DATE or YYMMDD format so that users do not mistake October Twelfth for the Tenth of December.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2022 18:59:58 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-07-18T18:59:58Z</dc:date>
    <item>
      <title>Data format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-format/m-p/823932#M35099</link>
      <description>&lt;P&gt;Changing the data format&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Date&lt;/P&gt;&lt;P&gt;19431010&lt;/P&gt;&lt;P&gt;Change Date to:&lt;/P&gt;&lt;P&gt;10/10/1943(mm/dd/yyyy)&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 18:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-format/m-p/823932#M35099</guid>
      <dc:creator>Smitha9</dc:creator>
      <dc:date>2022-07-18T18:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-format/m-p/823944#M35100</link>
      <description>&lt;P&gt;SAS only has two types of variables, floating point numbers and fixed length character strings.&lt;/P&gt;
&lt;P&gt;Which type is the source variable?&amp;nbsp; What type do you want to create?&lt;/P&gt;
&lt;P&gt;Note that SAS stores date values as numbers, the number of days since 1960.&lt;/P&gt;
&lt;P&gt;So to convert the string '19431010' to a date use the INPUT() function with the YYMMDD8. informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;real_date = input(date,yymmdd8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To convert the number 19,431,010 to date first convert it to a string using the PUT() function and the Z8. format.&amp;nbsp; Then use the same method as above to convert string to a date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;real_date = input(put(date,z8.),yymmdd8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have a date value you can then use any date type format with it you want so that the number of days prints as a string that humans can understand.&amp;nbsp; Do make it print like MM/DD/YYYY use the MMDDYY10. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format real_date mmddyy10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to create a character variable instead then use the PUT() function to convert the date value to a string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_string=put(real_date,mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS Do not display dates in either MDY or DMY order as either choice will confuse half of your audience.&amp;nbsp; Better to use DATE or YYMMDD format so that users do not mistake October Twelfth for the Tenth of December.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 18:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-format/m-p/823944#M35100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-18T18:59:58Z</dc:date>
    </item>
  </channel>
</rss>

