<?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: Importing excel file  with all variables as character. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462960#M70428</link>
    <description>&lt;P&gt;Its the same to read datalines of text file, which csv is:&lt;/P&gt;
&lt;PRE&gt;data xx;
  infile "....csv";
  input a $ b $ c $ d$ e$;
  array c{5} a b c d e;
  array n{5} a_n b_n c_n d_n e_n;
  do i=1 to 5;
    n{i}=ifn(c{i}="&amp;lt;llq",999,input(c{i},best.));
  end;
run;&lt;/PRE&gt;
&lt;P&gt;But you see from that how much more effort it is to work with transposed data.&lt;/P&gt;</description>
    <pubDate>Thu, 17 May 2018 09:57:15 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-05-17T09:57:15Z</dc:date>
    <item>
      <title>Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462942#M70422</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have an excel file I like to read into SAS. The dataset contains many variables that are both numeric character values, so I like to read the variables in the dataset as character. I saw some post that can enable read only one variable as character. But the dataset contains many variables that it will be challenging to list them all, so I want to read all variables as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg:&lt;/P&gt;
&lt;P&gt;data xx;&lt;/P&gt;
&lt;P&gt;input a b c d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;lt;llq&amp;nbsp; 4&amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;lt;llq 4&amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp;3&lt;/P&gt;
&lt;P&gt;4&amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;lt;llq&amp;nbsp; 4&lt;/P&gt;
&lt;P&gt;5&amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help will be appreciated:&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 08:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462942#M70422</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2018-05-17T08:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462946#M70423</link>
      <description>&lt;P&gt;Unfortunately Excel is a poor data medium (i.e. it is not well structured like a dataset or database) and I suppose you are using proc import - which is a guessing procedure.&amp;nbsp; There is no simple switch to allow you read all in as character as far as I am aware.&amp;nbsp; One easy solution is to add one row to you Excel file with "AAAAA" in each cell of each column (Select row, shift+right fill).&amp;nbsp; This way proc import will always "guess" the data to be character.&lt;/P&gt;
&lt;P&gt;Another alternative is to save to CSV file, then proc import that, in the log it will give you the code which it has used to import the file.&amp;nbsp; You can then modify that to match the formats and lengths you want - this is the best method for getting data in as it is accurate, repeatable and fully under you (as the data owners) control.&lt;/P&gt;
&lt;P&gt;A final method I can think of would be to write a VBA macro in Excel which writes out the Excel file to CSV, with all the data enclosed in double quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I suppose the real question here is why you want them all character, that data looks like lab results to me, therefore it would be far easier to work with in a normalised structure (E.g. CDISC LAB, or LB domain format).&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 08:18:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462946#M70423</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-17T08:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462947#M70424</link>
      <description>&lt;P&gt;Standard answer: save to csv, import with data step. The only way to guarantee consistent repeatable results.&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 08:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462947#M70424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-17T08:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462950#M70425</link>
      <description>Thank you very much for your prompt and detailed reply. &lt;BR /&gt;Yes, it's lab data. The reason I want to read all variable in as character is that after reading the data, I can impute the LLQ and then multiply the variables by I to convert them to numeric. &lt;BR /&gt;That is the only way I can think of handling the issue.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 May 2018 09:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462950#M70425</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2018-05-17T09:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462954#M70426</link>
      <description>&lt;P&gt;There is nothing stopping you doing imputation or anything with a normalised data structure.&amp;nbsp; Let me show with the data you provided;&lt;/P&gt;
&lt;PRE&gt;data xx;
  input char_result $ @@;
  numeric_result=ifn(char_result="&amp;lt;llq",999,input(char_result,best.));
datalines;
2    &amp;lt;llq  4  6
&amp;lt;llq 4    5   3
4    6  &amp;lt;llq  4
5   6   3   1
;
run;&lt;/PRE&gt;
&lt;P&gt;In this way I retain the original data, and the converted numeric variant.&amp;nbsp; This is how CDISC models work by having both.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 09:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462954#M70426</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-17T09:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462957#M70427</link>
      <description>Thank you very much. But the data set is in excel which I will convert to csv per you initial reply.&amp;nbsp;&lt;BR /&gt;I gave example with input statement to show how the data looks like. &lt;BR /&gt;I will appreciate a code for how I can read in the CSV format into SAS assumming 5 variables four of which have mixed variable type. &lt;BR /&gt;Thanks again.</description>
      <pubDate>Thu, 17 May 2018 09:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462957#M70427</guid>
      <dc:creator>SWEETSAS</dc:creator>
      <dc:date>2018-05-17T09:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462960#M70428</link>
      <description>&lt;P&gt;Its the same to read datalines of text file, which csv is:&lt;/P&gt;
&lt;PRE&gt;data xx;
  infile "....csv";
  input a $ b $ c $ d$ e$;
  array c{5} a b c d e;
  array n{5} a_n b_n c_n d_n e_n;
  do i=1 to 5;
    n{i}=ifn(c{i}="&amp;lt;llq",999,input(c{i},best.));
  end;
run;&lt;/PRE&gt;
&lt;P&gt;But you see from that how much more effort it is to work with transposed data.&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 09:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/462960#M70428</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-17T09:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Importing excel file  with all variables as character.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/463014#M70430</link>
      <description>&lt;P&gt;I think it depends *how* you import the Excel file.&amp;nbsp; Some engines (such as PCFILES server) support the DBSASTYPE option which allows you to force that data be read from Excel as character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I submitted a SASware&amp;nbsp; ballot idea to add such an option for the XLSX engine:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-DBSASTYPE-or-similar-option-to-XLSX-engine-to-force-variable/idi-p/453938" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/Add-DBSASTYPE-or-similar-option-to-XLSX-engine-to-force-variable/idi-p/453938&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Related thread:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Reading-XLSX-file-and-force-SAS-column-types/m-p/430934#M106536" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Reading-XLSX-file-and-force-SAS-column-types/m-p/430934#M106536&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 14:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-excel-file-with-all-variables-as-character/m-p/463014#M70430</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-05-17T14:33:24Z</dc:date>
    </item>
  </channel>
</rss>

