<?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: PROC IMPORT Unable to read empty cells in a timestamp column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699005#M213819</link>
    <description>&lt;P&gt;Welcome to the ugly world of Excel and no settings of datatype.&lt;/P&gt;
&lt;P&gt;Proc import uses a limited number of rows to set properties when reading from Excel. If any of the values in the first rows are blank the rules tell SAS to treat the column as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to avoid this is to 1) Save the file from Excel to CSV using the File Save As menu. and 2) use import to read the CSV file and add the GUESSINGROWS=MAX; statement to the proc import code. That way more rows will be examined before setting properties.&lt;/P&gt;
&lt;P&gt;If you are going to read multiple files of the same supposed content, which sounds likely, then copy the data step code that appears in the log to editor, clean up the code by removing the line numbers and consider the lengths of the character variables. You may want to make them 15 to 25 percent longer unless you have a document that indicates what the maximum length of each variable should be..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAVE the code and you can read similar structured data by saving them to csv, changing the Infile statement to point to the new file and change the output data set name if desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 15 Nov 2020 22:38:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-15T22:38:02Z</dc:date>
    <item>
      <title>PROC IMPORT Unable to read empty cells in a timestamp column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699000#M213817</link>
      <description>&lt;P&gt;Hello all - I am trying to use PROC IMPORT to read data from an EXCEL file, code below.&amp;nbsp; The columns that are giving me trouble are timestamps that are formatted like this (12/11/2018 4:02:39 PM) in the excel spreadsheet.&amp;nbsp; The issue is that if the first row has an empty cell then the format of the data changes.&amp;nbsp; If the first row has a timestamp then the data comes in formatted like this (09JUN2020 12:13:14), if the first row is blank then the rows that have timestamps come in formatted like this (06/09/2020 12:13:14).&amp;nbsp; I have tried to force the data type by using the DBDSOPT option and I used DATETIMEw, ANYDTDTTMw and CHAR(w) and none worked.&amp;nbsp; Any help is appreciated.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT OUT=&amp;amp;outfile.
DATAFILE= &amp;amp;infile. 
DBMS=EXCELCS REPLACE;
RANGE="&amp;amp;sheetname.$";
DBDSOPTS= " DBTYPE=('UNDER_REVIEW_TS'='DATETIME19.' 'final_status_ts'='DATETIME19.' ) ";
TEXTSIZE=32767;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
SERVER="server_name";
PORT=1235;
SERVERUSER=&amp;amp;user_id.;
SERVERPASS=&amp;amp;pass_word.; 
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Nov 2020 20:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699000#M213817</guid>
      <dc:creator>SyidaRox</dc:creator>
      <dc:date>2020-11-15T20:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT Unable to read empty cells in a timestamp column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699005#M213819</link>
      <description>&lt;P&gt;Welcome to the ugly world of Excel and no settings of datatype.&lt;/P&gt;
&lt;P&gt;Proc import uses a limited number of rows to set properties when reading from Excel. If any of the values in the first rows are blank the rules tell SAS to treat the column as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to avoid this is to 1) Save the file from Excel to CSV using the File Save As menu. and 2) use import to read the CSV file and add the GUESSINGROWS=MAX; statement to the proc import code. That way more rows will be examined before setting properties.&lt;/P&gt;
&lt;P&gt;If you are going to read multiple files of the same supposed content, which sounds likely, then copy the data step code that appears in the log to editor, clean up the code by removing the line numbers and consider the lengths of the character variables. You may want to make them 15 to 25 percent longer unless you have a document that indicates what the maximum length of each variable should be..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAVE the code and you can read similar structured data by saving them to csv, changing the Infile statement to point to the new file and change the output data set name if desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Nov 2020 22:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699005#M213819</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-15T22:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT Unable to read empty cells in a timestamp column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699119#M213856</link>
      <description>&lt;P&gt;You don't seem to using the right option there.&amp;nbsp; DBTYPE= is for setting the type to use when creating a variable in the remote database.&amp;nbsp; So you would use that with PROC EXPORT not PROC IMPORT.&amp;nbsp; DBSASTYPE= is for telling it what type to use when creating the variable in the SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also do not seem to be setting the type properly. It wants you to tell it the type, not a SAS format or informat name. For DATETIME values just use DATETIME.&amp;nbsp; If you want to change how the values are displayed then you can attach a different format to the variable later.&amp;nbsp; If there is not a format that displays datetime values the way you like then roll your own with PROC FORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="n0xm28d2csxt7un1klb3xwuq7v5i" class="xisDoc-syntaxSimple"&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-syntaxLevel"&gt;&lt;SPAN class="xisDoc-keyword"&gt;DBSASTYPE=&lt;/SPAN&gt;(&lt;SPAN class="xisDoc-choice"&gt;&lt;A tabindex="0" title="Description of syntax: “column-name”" href="https://documentation.sas.com/n0v4ma1zb9lu99n1728j279rjcqi.htm#p1teo1x5du4y4rn1c1gjq85a6eo1" target="_blank" rel="noopener" data-docset-id="acreldb" data-docset-version="9.4" data-original-href="n0v4ma1zb9lu99n1728j279rjcqi.htm#p1teo1x5du4y4rn1c1gjq85a6eo1"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;column-name-1&lt;/EM&gt;&lt;/A&gt;&lt;/SPAN&gt;=&amp;lt;'&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-choice"&gt;&lt;A class="" tabindex="0" title="Description of syntax: “SAS-data-type”" href="https://documentation.sas.com/n0v4ma1zb9lu99n1728j279rjcqi.htm#p1fqex1agxsnj1n1ar5x4qssonkb" target="_blank" rel="noopener" data-docset-id="acreldb" data-docset-version="9.4" data-original-href="n0v4ma1zb9lu99n1728j279rjcqi.htm#p1fqex1agxsnj1n1ar5x4qssonkb"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;SAS-data-type&lt;/EM&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;'&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;&lt;EM class="xisDoc-userSuppliedValue"&gt;…&lt;/EM&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;column-name-n&lt;/EM&gt;=&amp;lt;'&amp;gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;SAS-data-type&lt;/EM&gt;&amp;lt;'&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;)&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;
&lt;DIV class="xisDoc-syntaxDescription"&gt;
&lt;DIV class="xisDoc-otherArgGroup"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H3 id="p043zjfglk4ygln1d7f5mkqskood" class="xisDoc-title"&gt;Syntax Description&lt;/H3&gt;
&lt;DIV id="p1teo1x5du4y4rn1c1gjq85a6eo1" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;column-name&lt;/EM&gt;&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies a DBMS column name.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV id="p1fqex1agxsnj1n1ar5x4qssonkb" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;SAS-data-type&lt;/EM&gt;&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies a SAS data type, which can be CHAR(&lt;EM class="xisDoc-userSuppliedValue"&gt;n&lt;/EM&gt;), NUMERIC, DATETIME, DATE, TIME. See the DBMS-specific reference section for your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-nobr"&gt;SAS/ACCESS&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;interface for details.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Nov 2020 13:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-IMPORT-Unable-to-read-empty-cells-in-a-timestamp-column/m-p/699119#M213856</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-16T13:07:29Z</dc:date>
    </item>
  </channel>
</rss>

