<?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 types of variable informat in proc import in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440584#M69219</link>
    <description>&lt;P&gt;Try GUESSINGROWS=MAX but I would strongly recommend using the data step approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Run a PROC IMPORT once, copy the code from the log. Make sure all types/formats are correct and use that inside your macro instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178913"&gt;@Rickyboy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Good morning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i m trying to write a macro that imports some csv files and then appends them&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; import(start,end);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;start.&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;end.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DATAFILE=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"C\data&amp;amp;i..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;OUT=work.data&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;import&lt;/I&gt;&lt;/STRONG&gt;(start=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, end=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;22&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works&lt;/P&gt;
&lt;P&gt;except for the fact that sometimes it imports some of the columns as text and some other as values , which means that the successive APPEND procedure fails because the columns are not the same&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a way I can specify the informat for these 2 columns or alternatively import everything as text and then change it into my desired format once I have appended the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand this is due to the algorithm used to determine if a column is text or number used by sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have looked at the documentation for sas and I m not sure any of the option listed are relevant&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;A frustrated user !&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2018 16:54:09 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-27T16:54:09Z</dc:date>
    <item>
      <title>specify types of variable informat in proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440564#M69217</link>
      <description>&lt;P&gt;Good morning&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i m trying to write a macro that imports some csv files and then appends them&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; import(start,end);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;start.&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;end.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DATAFILE=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"C\data&amp;amp;i..csv"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;OUT=work.data&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;import&lt;/I&gt;&lt;/STRONG&gt;(start=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, end=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;22&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works&lt;/P&gt;&lt;P&gt;except for the fact that sometimes it imports some of the columns as text and some other as values , which means that the successive APPEND procedure fails because the columns are not the same&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way I can specify the informat for these 2 columns or alternatively import everything as text and then change it into my desired format once I have appended the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand this is due to the algorithm used to determine if a column is text or number used by sas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have looked at the documentation for sas and I m not sure any of the option listed are relevant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;A frustrated user !&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 16:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440564#M69217</guid>
      <dc:creator>Rickyboy</dc:creator>
      <dc:date>2018-02-27T16:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: specify types of variable informat in proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440575#M69218</link>
      <description>&lt;P&gt;Drop the proc import - this is a guessing procedure hence why you get different results.&lt;/P&gt;
&lt;P&gt;Write a datastep import (you can use the output from the proc import to save time typing it all in).&amp;nbsp; In this you can specify formats, informats, lengths, labels etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using wildcard notation you can read all the csv files in one go.&amp;nbsp; See:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/td-p/184804" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Help-merging-multiple-CSV-files-to-a-dataset/td-p/184804&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 16:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440575#M69218</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-27T16:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: specify types of variable informat in proc import</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440584#M69219</link>
      <description>&lt;P&gt;Try GUESSINGROWS=MAX but I would strongly recommend using the data step approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Run a PROC IMPORT once, copy the code from the log. Make sure all types/formats are correct and use that inside your macro instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178913"&gt;@Rickyboy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Good morning&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i m trying to write a macro that imports some csv files and then appends them&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; import(start,end);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;start.&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;end.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DATAFILE=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"C\data&amp;amp;i..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;OUT=work.data&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;import&lt;/I&gt;&lt;/STRONG&gt;(start=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, end=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;22&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works&lt;/P&gt;
&lt;P&gt;except for the fact that sometimes it imports some of the columns as text and some other as values , which means that the successive APPEND procedure fails because the columns are not the same&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a way I can specify the informat for these 2 columns or alternatively import everything as text and then change it into my desired format once I have appended the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand this is due to the algorithm used to determine if a column is text or number used by sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have looked at the documentation for sas and I m not sure any of the option listed are relevant&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;A frustrated user !&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 16:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/specify-types-of-variable-informat-in-proc-import/m-p/440584#M69219</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-27T16:54:09Z</dc:date>
    </item>
  </channel>
</rss>

