<?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: specify data type in proc import for excel file in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358114#M9801</link>
    <description>I tried you code, but the character value was still set to missing after import</description>
    <pubDate>Fri, 12 May 2017 04:22:53 GMT</pubDate>
    <dc:creator>ynchen08</dc:creator>
    <dc:date>2017-05-12T04:22:53Z</dc:date>
    <item>
      <title>specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357560#M9795</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Hi all, &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I would like to import an excel file (all fields&amp;nbsp;are formatted as "General") to SAS. The field, "Result", contains numerical values for some observations and character values for other observations. When I first imported the excel worksheet to SAS, I realized that the result field was imported solely as a numerical field (i.e., the character values for the result field all become missing). &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;So&amp;nbsp;I tried to use the following code to specify that I would like to import&amp;nbsp;"Result" as character field instead of numerical field. However, it does not seem like the code is working. Would someone please help me fix this issue? Thank you very much in advance!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;import&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Z:\Positive Health Check\Data\1985-2017May Data\test2.xlsx"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=ts&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DBMS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=EXCEL replace;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;DBDSOPTS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"DBTYPE=(RESULT='CHAR(20)')"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 16:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357560#M9795</guid>
      <dc:creator>ynchen08</dc:creator>
      <dc:date>2017-05-10T16:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357570#M9796</link>
      <description>&lt;P&gt;First question is whether you can use the Excel engine. What code did you submit that resulted in the missing values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 16:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357570#M9796</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-10T16:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357685#M9797</link>
      <description>&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 21:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357685#M9797</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-10T21:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357747#M9798</link>
      <description>&lt;P&gt;Thanks for your prompt response! By "does not work", I meant the field, "Result", is still imported as numerical variable (i.e., the character values were set to missing in my temporary sas dataset). Here I am attaching a testing dataset, which includes the three fields (patient, test_name, result). The result field can have either number of CD4 count or positive/negative test result, depending on the associated lab test name. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following text is the log when I ran my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;617 proc import file="C:\Users\Enoch\Desktop\SAS 9.4\test_Excel.xlsx" out=test6&lt;BR /&gt;617! DBMS=Excel replace;&lt;BR /&gt;618 DBDSOPTS= "DBTYPE=(Result='CHAR(20)')";&lt;BR /&gt;619 run;&lt;/P&gt;&lt;P&gt;NOTE: WORK.TEST6 data set was successfully created.&lt;BR /&gt;NOTE: The data set WORK.TEST6 has 130 observations and 3 variables.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.37 seconds&lt;BR /&gt;cpu time 0.12 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The imported result field was set to missing for character values:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8807i95BCE9909D861FB1/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="result.PNG" title="result.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 03:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357747#M9798</guid>
      <dc:creator>ynchen08</dc:creator>
      <dc:date>2017-05-11T03:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357750#M9799</link>
      <description>&lt;P&gt;Since you can use the Excel engine, try to import it with the following code:&lt;/P&gt;
&lt;PRE&gt;proc import datafile="&lt;SPAN&gt;C:\Users\Enoch\Desktop\SAS 9.4\test_Excel.xlsx" out=test6&lt;/SPAN&gt; replace dbms=excel;
  getnames=yes;
  mixed=yes;
  sheet='Sheet1';
  usedate=yes;
  scantime=yes;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 04:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/357750#M9799</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-11T04:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358066#M9800</link>
      <description>&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;If you're using &amp;nbsp;SAS 9.4, then you can try the XLSX engine:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='test_Excel.xlsx'
  out=work.test_Excel
  replace
  dbms=xlsx;
  sheet='Sheet1';
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Vince DelGobbo&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;SAS R&amp;amp;D&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 23:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358066#M9800</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2017-05-11T23:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358114#M9801</link>
      <description>I tried you code, but the character value was still set to missing after import</description>
      <pubDate>Fri, 12 May 2017 04:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358114#M9801</guid>
      <dc:creator>ynchen08</dc:creator>
      <dc:date>2017-05-12T04:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358117#M9802</link>
      <description>&lt;P&gt;Thanks! it works.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 04:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358117#M9802</guid>
      <dc:creator>ynchen08</dc:creator>
      <dc:date>2017-05-12T04:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: specify data type in proc import for excel file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358118#M9803</link>
      <description>Actually, your code works. I just realized that I had a typo in my coding before. Sorry for the confusion! Thanks for your helpful feedback!</description>
      <pubDate>Fri, 12 May 2017 04:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/specify-data-type-in-proc-import-for-excel-file/m-p/358118#M9803</guid>
      <dc:creator>ynchen08</dc:creator>
      <dc:date>2017-05-12T04:32:55Z</dc:date>
    </item>
  </channel>
</rss>

