<?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: How do I change length of each variable in my dataset all at once? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898822#M43850</link>
    <description>How are you reading the data from Impala to SAS?</description>
    <pubDate>Mon, 16 Oct 2023 15:46:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-10-16T15:46:40Z</dc:date>
    <item>
      <title>How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898821#M43849</link>
      <description>&lt;P&gt;I am tapping into Impala on SAS, all my column lengths are default to 32767 for character variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to quickly format their lengths to default lengths. however my dataset is a daily refresh and it has lot more records than expected and if i try to run though the data SAS is crashing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any work around or a macro to help this situation? this is only for character variables, numeric formats have no issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see below the proc contents for couple variables.&amp;nbsp; it is easier to do a proc sql step by formatting each column but there are some tables that I need almost 25 variables that i have to write code for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PrudhviB_0-1697470813978.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88898i1DD7D2697D610A25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PrudhviB_0-1697470813978.png" alt="PrudhviB_0-1697470813978.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;My data tables have almost more than some million records. it is hard to go over each observation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 15:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898821#M43849</guid>
      <dc:creator>PrudhviB</dc:creator>
      <dc:date>2023-10-16T15:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898822#M43850</link>
      <description>How are you reading the data from Impala to SAS?</description>
      <pubDate>Mon, 16 Oct 2023 15:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898822#M43850</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-16T15:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898824#M43852</link>
      <description>&lt;P&gt;I am using two ways to do it&amp;nbsp; as below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. using a DB connection method : this method takes forever to load values so have to pull 10-25 observations at a time to work on it&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;proc sql outobs = 25;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;connect to impala(dsn="********" user=****** password=******** dsn='******');&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;create table Sample as&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;select * from connection to impala (&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;select *&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;from z4_data.v_tablename_ts&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;);&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;quit;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;2. using a library statement like any other datasets : my database team mapped Impala connection in the background so I can access it via simple library statement, this one by far is better than the first connection however i have limitation with the column lengths and also table name lengths (&amp;gt; 32)&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;LIBNAME EDH META LIBRARY = 'AAE-EDH_ z4_data' metaout=data;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Trebuchet MS'; font-size: 11.0pt;" lang="en-CA"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 16:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898824#M43852</guid>
      <dc:creator>PrudhviB</dc:creator>
      <dc:date>2023-10-16T16:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898828#M43854</link>
      <description>Ideally, talk to the Impala DB to get the actual structure of the data and then map that to the SAS code. &lt;BR /&gt;If it's provided as an Excel/CSV that can be modified to the appropriate code. &lt;BR /&gt;&lt;BR /&gt;If that's not possible for whatever reason, I would access as much data as possible using the second method. For the first, I would get extracts of 1000 rows or so, check proc datasets and generate code to automatically trim the lengths in the select phase. &lt;BR /&gt;&lt;BR /&gt;You could try something like length _character_ 500. in a data step but I don't think it will work, as length is set  before the data is read in. I think you'll have to generate your code or manually create it once and hopefully that works for you going forward.</description>
      <pubDate>Mon, 16 Oct 2023 16:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898828#M43854</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-10-16T16:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898843#M43856</link>
      <description>&lt;P&gt;A couple of things to try to improve performance:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Turn on the SAS compression option to ensure the long character variables don't increase dataset size.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options compress = yes;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;Try the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p14o73fqwbby7xn1iqvjbdiixuyj.htm" target="_blank" rel="noopener"&gt;DBMAXTEXT&lt;/A&gt; option to set a smaller maximum length for character variables.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 19:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898843#M43856</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-10-16T19:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898872#M43857</link>
      <description>&lt;P&gt;This happens because of Impala data types without a length specification.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0usrxwbz3hw7qn1nqb2zwp1ho84.htm" target="_self"&gt;Data Conversion from Impala to SAS&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1697511574875.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88903i5F3B5D87BEF50FAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1697511574875.png" alt="Patrick_0-1697511574875.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Setting&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p14o73fqwbby7xn1iqvjbdiixuyj.htm" target="_blank" rel="nofollow noopener noreferrer"&gt;DBMAXTEXT&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;to a lower value like 4096 might change the default to 4KB instead of 32KB (not sure, you need to try) but that's of course only a not very satisfying work-around.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the Impala data types don't provide the information then you need either an impala view that casts the variables to types with lengths or you need to do this yourself in the explicit passthrough SQL (your option 1 with all the variables explicitly listed) or with a libname statement (your option 2) you could also use SAS ds option &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0v4ma1zb9lu99n1728j279rjcqi.htm" target="_self"&gt;DBSASTYPE&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you have the mapping information somewhere stored (DB variable type to SAS variable type and length) then it should also be possible to write some SAS logic that generates the code dynamically.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 03:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898872#M43857</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-17T03:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change length of each variable in my dataset all at once?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898876#M43858</link>
      <description>&lt;P&gt;Are you using some old version of IMPALA? Or have the creators of the database just been lazy and not bothered to define lengths for the variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/kb/53/835.html" target="_blank"&gt;https://support.sas.com/kb/53/835.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using a version of Impala that does support VARCHAR() type then use CAST() in passthru query to set the lengths.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname impala ..... ;
proc sql;
connect using impala;
create table want as select * from connection to impala
(select cast(acount_id as varchar(10)) as account_id
, id
, cast(submitted_channel as varchar(50)) as submitted_channel
from myschema.mytable
);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Oct 2023 04:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-do-I-change-length-of-each-variable-in-my-dataset-all-at/m-p/898876#M43858</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-17T04:39:59Z</dc:date>
    </item>
  </channel>
</rss>

