<?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: SAS/Access not reading MS Access ShortText properly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947448#M370901</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263372"&gt;@JacquesR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That works. Annoying that the documentation page I linked to does not mention DBSASTYPE.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I've used already multiple times the docu feedback button when I felt something is missing and several times my proposed changes actually made it into the docu.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1728968275428.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101208iA5E8883661760B6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1728968275428.png" alt="Patrick_0-1728968275428.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I also started to use AI assistance (mostly Copilot) when looking for solutions. Not that the answers are always correct but it's often giving me new ideas.&lt;/P&gt;
&lt;P&gt;If you want to test it with Copilot use below prompts and see what you get:&lt;/P&gt;
&lt;PRE&gt;proc import ms access short text to SAS character variable length 255&lt;/PRE&gt;
&lt;P&gt;...or even more fun: Just copy/paste your initial question into Copilot or similar.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2024 05:10:21 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-10-15T05:10:21Z</dc:date>
    <item>
      <title>SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947432#M370889</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code won't really help, but for what it's worth:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT
    OUT=WORK.Test
    TABLE="Info"
    DBMS=ACCESS
    REPLACE;
    DATABASE="&amp;lt;path&amp;gt;\&amp;lt;dataset&amp;gt;.accdb";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My problem is this.&lt;/P&gt;
&lt;P&gt;I have a large amount of importing to do (about 20 datasets, 6 tables per dataset). The code above is nested in a macro which does the import quite nicely.&lt;/P&gt;
&lt;P&gt;but...&lt;/P&gt;
&lt;P&gt;The table Info contains three fields all using the ShortText data type, using the default length of 255.&lt;/P&gt;
&lt;P&gt;SAS is aware of MS Access data types:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/acpcref/63181/HTML/default/viewer.htm#p0psac3j16cioen1nq2hkwrnk55y.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/acpcref/63181/HTML/default/viewer.htm#p0psac3j16cioen1nq2hkwrnk55y.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;These three fields, however, have many empty rows, and some rows with text, sometimes quite long text.&lt;/P&gt;
&lt;P&gt;When SAS does the import, it is importing these three columns as very short ($3 or $4) based on the length of the first non-empty row, instead of using the full column width ($255).&lt;/P&gt;
&lt;P&gt;If these were csv files, I could use guessingrows=max, but that is not an option with the Access files.&lt;/P&gt;
&lt;P&gt;I have looked through the various SAS options for DBMS=ACCESS (see link above) but while there are options to control how dates and times are imported, no such options exist for ShortText. Also, there are many ShortText fields, but it seems to be reasonably uniquely these three that SAS is truncating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas as to how I can fix it, without having to export each of those databases manually?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 00:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947432#M370889</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2024-10-15T00:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947433#M370890</link>
      <description>&lt;P&gt;I'd still be interested to hear suggestions, but I realised I could use this approach for my macro instead:&lt;/P&gt;
&lt;P&gt;Create a SAS/ACCESS LIBNAME to the database.&lt;/P&gt;
&lt;P&gt;Read the table (using SAS name literals) and write it to a SAS dataset using PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A quick test shows that these variables are now reading properly from at least one dataset when using the LIBNAME.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I may post some basic code when I am done.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 01:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947433#M370890</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2024-10-15T01:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947435#M370891</link>
      <description>&lt;P&gt;Using Proc Import have you tried DBSASTYPE? I believe syntax similar to below could work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT 
    DATAFILE="C:\path\to\your\database.accdb" 
    OUT=work.mydata 
    DBMS=ACCESS REPLACE;
    TABLE="YourTableName";
    DBSASTYPE=('ShortTextColumn'='CHAR(255)');
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2024 01:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947435#M370891</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-15T01:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947437#M370893</link>
      <description>Patrick,&lt;BR /&gt;Should like this:&lt;BR /&gt;&lt;BR /&gt;proc import datafile = "c:\temp\date.xlsx" out =have replace dbms =excel ;&lt;BR /&gt;dbdsopts="dbsastype=(age='numeric' weight='char(20)' weight='char(20)')";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;libname x excel 'c:\temp\date.xlsx';&lt;BR /&gt;data have2;&lt;BR /&gt;set x.'date$'n(dbsastype=(age='numeric' weight='char(20)' weight='char(20)'));&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947437#M370893</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-10-15T02:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947440#M370896</link>
      <description>&lt;P&gt;You seem to have some good suggestions for how to tell PROC IMPORT what SAS types to use for the variables.&lt;/P&gt;
&lt;P&gt;But the old SAS 9.3 documentation you linked also says there is a SCANMEMO option of the SAS/Access to MS Access files.&amp;nbsp; Setting that to YES will tell it to scan all of the memo fields and set the length to longest string, instead of just setting it to the first value.&amp;nbsp; You might try using that option in your macro and see if PROC IMPORT can make better GUESSES about what length to use for those variables.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 02:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947440#M370896</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-15T02:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947444#M370899</link>
      <description>&lt;P&gt;Tom, the documentation notes:&lt;/P&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV id="p0psac3j16cioen1nq2hkwrnk55y" class="xis-topic"&gt;
&lt;DIV id="n0myi8x1y357uen1dwp75zfn5yyb" class="xis-subTopic"&gt;
&lt;DIV id="p0ukegmdq3lphzn1ucyojgffrle8" class="xis-subSubTopic"&gt;
&lt;DIV id="n09kknsf1vor4mn1fko7fjapzwma" class="xis-topicContent"&gt;
&lt;DIV id="n0r4tzvin1u5tun1o7o7rhd0kd6d" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD rowspan="2" class="xis-restriction"&gt;Restrictions&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;SCANMEMO= applies only to MEMO data type columns; it does not apply to TEXT type columns.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 15 Oct 2024 03:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947444#M370899</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2024-10-15T03:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947445#M370900</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That works. Annoying that the documentation page I linked to does not mention DBSASTYPE.&lt;/P&gt;
&lt;P&gt;For what it's worth, this is what the Import statement in the macro looks like now, and it works. So that has spared me rewriting the macro to use the LIBNAME with PROC SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    PROC IMPORT
        OUT=WORK.D_&amp;amp;newtable._&amp;amp;n.
        TABLE="&amp;amp;table."
        DBMS=ACCESS
        REPLACE;
        %IF &amp;amp;newtable. EQ DDI_Info %THEN %DO;
    		DBDSOPTS="DBSASTYPE=('Drug_Factors'='CHAR(255)' 'Patient_Factors'='CHAR(255)' 'Clinical_Factors'='CHAR(255)')"; 
		%END;
        DATABASE=&amp;amp;dfile.;
    RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Oct 2024 03:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947445#M370900</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2024-10-15T03:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS/Access not reading MS Access ShortText properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947448#M370901</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263372"&gt;@JacquesR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That works. Annoying that the documentation page I linked to does not mention DBSASTYPE.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I've used already multiple times the docu feedback button when I felt something is missing and several times my proposed changes actually made it into the docu.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1728968275428.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101208iA5E8883661760B6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1728968275428.png" alt="Patrick_0-1728968275428.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I also started to use AI assistance (mostly Copilot) when looking for solutions. Not that the answers are always correct but it's often giving me new ideas.&lt;/P&gt;
&lt;P&gt;If you want to test it with Copilot use below prompts and see what you get:&lt;/P&gt;
&lt;PRE&gt;proc import ms access short text to SAS character variable length 255&lt;/PRE&gt;
&lt;P&gt;...or even more fun: Just copy/paste your initial question into Copilot or similar.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 05:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Access-not-reading-MS-Access-ShortText-properly/m-p/947448#M370901</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-15T05:10:21Z</dc:date>
    </item>
  </channel>
</rss>

