<?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 Reading access database with infile statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495667#M130862</link>
    <description>&lt;P&gt;&lt;STRONG&gt;TLDR:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I want to read my access database via infile statement to have complete control over format,informat,length of variables/columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an access database which has around 2 million records.Currently I am importing it with &lt;STRONG&gt;PROC IMPORT.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;From what I have read that&amp;nbsp;&lt;STRONG&gt;PROC IMPORT&amp;nbsp;&lt;/STRONG&gt;uses around 32k rows to set format,informat,length for variables I feel that data may be getting truncated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another problem is all my character variables have format and informat as $255.and length as 255.I&amp;nbsp; dont want my all variables to be of this length,format,informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some I want to be more than 255 and some to be less than that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My current code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC IMPORT OUT= Input.access_db 
DATATABLE= "DATABASE" 
DBMS=ACCESSCS REPLACE; 
DATABASE="\\Input\Entire_Records.accdb"; 
SCANMEMO=YES; 
USEDATE=YES; 
SCANTIME=NO; 
RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do above with an infile statement.&lt;/P&gt;&lt;P&gt;I have a code to import my csv via infile statement.But I am not getting how do I modify it to make it to read my access database&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Input.Real;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'Input\Real.csv'
delimiter = ',' 
MISSOVER 
DSD 
lrecl=32767 
firstobs=2 ;
informat DATE 11.;
informat IDENTIFIER $255. ;
informat LINE_CODE $255. ;
informat ACTION $255. ;

format DATE 11.;
format IDENTIFIER $255. ;
format LINE_CODE $255. ;
format ACTION $255. ;

input

DATE 
IDENTIFIER $
LINE_CODE $
ACTION $ ;

if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
RUN;


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 13:23:29 GMT</pubDate>
    <dc:creator>Rookie_123</dc:creator>
    <dc:date>2018-09-14T13:23:29Z</dc:date>
    <item>
      <title>Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495667#M130862</link>
      <description>&lt;P&gt;&lt;STRONG&gt;TLDR:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I want to read my access database via infile statement to have complete control over format,informat,length of variables/columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an access database which has around 2 million records.Currently I am importing it with &lt;STRONG&gt;PROC IMPORT.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;From what I have read that&amp;nbsp;&lt;STRONG&gt;PROC IMPORT&amp;nbsp;&lt;/STRONG&gt;uses around 32k rows to set format,informat,length for variables I feel that data may be getting truncated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another problem is all my character variables have format and informat as $255.and length as 255.I&amp;nbsp; dont want my all variables to be of this length,format,informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some I want to be more than 255 and some to be less than that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My current code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC IMPORT OUT= Input.access_db 
DATATABLE= "DATABASE" 
DBMS=ACCESSCS REPLACE; 
DATABASE="\\Input\Entire_Records.accdb"; 
SCANMEMO=YES; 
USEDATE=YES; 
SCANTIME=NO; 
RUN;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do above with an infile statement.&lt;/P&gt;&lt;P&gt;I have a code to import my csv via infile statement.But I am not getting how do I modify it to make it to read my access database&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data Input.Real;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'Input\Real.csv'
delimiter = ',' 
MISSOVER 
DSD 
lrecl=32767 
firstobs=2 ;
informat DATE 11.;
informat IDENTIFIER $255. ;
informat LINE_CODE $255. ;
informat ACTION $255. ;

format DATE 11.;
format IDENTIFIER $255. ;
format LINE_CODE $255. ;
format ACTION $255. ;

input

DATE 
IDENTIFIER $
LINE_CODE $
ACTION $ ;

if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
RUN;


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 13:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495667#M130862</guid>
      <dc:creator>Rookie_123</dc:creator>
      <dc:date>2018-09-14T13:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495691#M130876</link>
      <description>&lt;P&gt;Infile is for reading files from disc.&amp;nbsp; Access databases, whilst files, are in MS file format.&amp;nbsp; As you say accdb its probably the most recent database file format, but it is definately not a flat file ready for reading.&amp;nbsp; You would need to export from Access a flat file format, like CSV to be able to read in the via infile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A better method (well, debatable as using any other an Office product would be better), would be to use odbc connection to access file and then read from access as if it was any other database connection:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-connect-SAS-to-MS-Access-query/td-p/459120" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-connect-SAS-to-MS-Access-query/td-p/459120&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 14:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495691#M130876</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-14T14:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495710#M130889</link>
      <description>The issues you're mentioning originate when the data is not in a database that enforces types whereas an Access DB does enforce types and other data integrity rules. For the variables that are set to 255 characters in SAS what is the length set in the Access DB?</description>
      <pubDate>Fri, 14 Sep 2018 14:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495710#M130889</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-14T14:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495711#M130890</link>
      <description>&lt;P&gt;The database is so large that I am not able to find its length in Access.I cant run any code on it to find its length outside SAS&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 14:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495711#M130890</guid>
      <dc:creator>Rookie_123</dc:creator>
      <dc:date>2018-09-14T14:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495713#M130892</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225671"&gt;@Rookie_123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The database is so large that I am not able to find its length in Access.I cant run any code on it to find its length outside SAS&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know how you're importing your data but you can look into PCFILES or ODBC connections which may help&amp;nbsp;with the field truncations. You do need to be sure that the truncation isn't in the ACCESS DB first though. For example if a field was set to limit 255 in Access that may be all that's present.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After you can scan your character variables using the LENGTH function and resize as necessary because you are correct that character variables do take up more space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 14:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495713#M130892</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-14T14:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495718#M130897</link>
      <description>&lt;P&gt;My main aim is whatever is in Access Database.I should get it in SAS database when I import.Basically I am not understanding that how SAS is setting 255 for character variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it because max length is 255 in the access database or is it because that's the max length it can set(Even if access database has say 300 in it)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495718#M130897</guid>
      <dc:creator>Rookie_123</dc:creator>
      <dc:date>2018-09-14T15:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495721#M130899</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225671"&gt;@Rookie_123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it because max length is 255 in the access database&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;is it because that's the max length it can set(Even if access database has say 300 in it)&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This can depend on how you import the file and your version of SAS. I don't believe using ODBC will have this issue.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495721#M130899</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-14T15:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495743#M130906</link>
      <description>&lt;P&gt;When I follow the link to connect to Access from SAS.&lt;/P&gt;&lt;P&gt;I get the error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE: Statement not executed due to NOEXEC option.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495743#M130906</guid>
      <dc:creator>Rookie_123</dc:creator>
      <dc:date>2018-09-14T15:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading access database with infile statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495747#M130908</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225671"&gt;@Rookie_123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;When I follow the link to connect to Access from SAS.&lt;/P&gt;
&lt;P&gt;I get the error&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOTE: Statement not executed due to NOEXEC option.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure how you "follow a link" to connect to Acess, but that note makes it look like SAS has set the NOEXEC option. Probably in response to early errors that have occured.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try just re-starting SAS and doing whatever you are trying again.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 16:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-access-database-with-infile-statement/m-p/495747#M130908</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-14T16:00:38Z</dc:date>
    </item>
  </channel>
</rss>

