<?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: date format while import the excel file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879017#M347287</link>
    <description>&lt;P&gt;PROC IMPORT is going to create the type and length of the variables based on what is in the cells in the column of the XLSX file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the column only has DATE values then it will create a numeric variable with data values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So then just add a step to change the format used to display the date values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=WORK nolist;
  modify ORDER_TABLE;
  format ord_date yymmdd10.;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you know the NAME of the first SHEET in the XLSX workbook then you could skip PROC IMPORT and use the XLSX libname engine instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxlsx xlsx '/home/u35263349/orders.xlsx';
data order_table;
  set myxlsx.SHEET1 ;
  format ord_date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And if (as is not uncommon with XLSX files) the column has a mix of numeric and character cells or just has those digits strings you showed as numbers or character strings then SAS will not make the variable a DATE value and you will have to add a data step to convert what ever it did create into date values before you can attach a date type format to it.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2023 14:42:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-06-02T14:42:06Z</dc:date>
    <item>
      <title>date format while import the excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/878940#M347263</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;
&lt;P&gt;How to change date format using proc import for excel file&lt;/P&gt;
&lt;TABLE width="389"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="58"&gt;ord_no&lt;/TD&gt;
&lt;TD width="73"&gt;purch_amt&lt;/TD&gt;
&lt;TD width="63"&gt;ord_date&lt;/TD&gt;
&lt;TD width="71"&gt;custom_id&lt;/TD&gt;
&lt;TD width="124"&gt;&amp;nbsp;salesman_id&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;70001&lt;/TD&gt;
&lt;TD&gt;150.5&lt;/TD&gt;
&lt;TD&gt;20121005&lt;/TD&gt;
&lt;TD&gt;3005&lt;/TD&gt;
&lt;TD&gt;5002&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;70009&lt;/TD&gt;
&lt;TD&gt;270.65&lt;/TD&gt;
&lt;TD&gt;20120910&lt;/TD&gt;
&lt;TD&gt;3001&lt;/TD&gt;
&lt;TD&gt;5005&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;70002&lt;/TD&gt;
&lt;TD&gt;65.26&lt;/TD&gt;
&lt;TD&gt;20121005&lt;/TD&gt;
&lt;TD&gt;3002&lt;/TD&gt;
&lt;TD&gt;5001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;70004&lt;/TD&gt;
&lt;TD&gt;110.5&lt;/TD&gt;
&lt;TD&gt;20120817&lt;/TD&gt;
&lt;TD&gt;3009&lt;/TD&gt;
&lt;TD&gt;5003&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='/home/u35263349/orders.xlsx'
out=order_table
dbms=xlsx
DBSASTYPE (ord_date) = (FORMAT = yymmdd10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 11:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/878940#M347263</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-06-02T11:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: date format while import the excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879003#M347275</link>
      <description>&lt;P&gt;Format should be on a separate statement. The correct syntax for the format statement is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;format ord_date yymmdd10. ;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879003#M347275</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2023-06-02T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: date format while import the excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879017#M347287</link>
      <description>&lt;P&gt;PROC IMPORT is going to create the type and length of the variables based on what is in the cells in the column of the XLSX file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the column only has DATE values then it will create a numeric variable with data values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So then just add a step to change the format used to display the date values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=WORK nolist;
  modify ORDER_TABLE;
  format ord_date yymmdd10.;
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you know the NAME of the first SHEET in the XLSX workbook then you could skip PROC IMPORT and use the XLSX libname engine instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxlsx xlsx '/home/u35263349/orders.xlsx';
data order_table;
  set myxlsx.SHEET1 ;
  format ord_date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And if (as is not uncommon with XLSX files) the column has a mix of numeric and character cells or just has those digits strings you showed as numbers or character strings then SAS will not make the variable a DATE value and you will have to add a data step to convert what ever it did create into date values before you can attach a date type format to it.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879017#M347287</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-02T14:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: date format while import the excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879053#M347307</link>
      <description>&lt;P&gt;I would start with a bare import and then look at the results of Proc Content for the properties of the data set. Because of the many questionable things I see done in spreadsheet files it is quite possible that the "ord_date" isn't even a data value in the file, just a number impersonating a date because people see it that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So try running:&lt;/P&gt;
&lt;PRE&gt;proc import datafile='/home/u35263349/orders.xlsx'
out=order_table
dbms=xlsx
;
run;

proc contents data=order_table;
run;&lt;/PRE&gt;
&lt;P&gt;Then share the results of the Proc Contents output.&lt;/P&gt;
&lt;P&gt;Hint: if you see that your Ord_date is numeric with a format like BEST12. then the value is not a date and you need to do more get one. Not hard, one line of code in a data step to create and another to assign a format, just routine.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 15:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-format-while-import-the-excel-file/m-p/879053#M347307</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-02T15:49:55Z</dc:date>
    </item>
  </channel>
</rss>

