<?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: Error attempting to CREATE a DBMS table. in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921799#M20928</link>
    <description>&lt;P&gt;This starts to feel like something you should raise with SAS Tech Support.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2024 14:49:14 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-03-26T14:49:14Z</dc:date>
    <item>
      <title>Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921731#M20922</link>
      <description>&lt;P&gt;Hello everyone! I've spent the whole morning trying to figure this out, so im asking you for help:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code works and creates both tables WORK.VENDAS_INDV_MES and DB2VNOT.VENDAS_INDV_MES:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC SQL;
   CREATE TABLE WORK.VENDAS_INDV_MES AS 
   SELECT DISTINCT t1.AAAAMM, 
          t1.NR_UNCO_CTR_OPR, 
          t1.NR_CTR_OPR, 
          t1.CD_CLI, 
          t1.CD_CPNT_RSTD, 
          t1.CD_PRF_RSTD, 
          t1.DT_APRC, 
          t1.MES, 
          t1.ANO, 
          t1.CD_DIRETORIA, 
          t1.NM_DIRETORIA, 
          t1.SUPER, 
          t1.NM_SUPER, 
          t1.CD_GEREV,
          t1.NM_GEREV, 
          t1.PREFIXO_FUNCI, 
          t1.NM_PREFIXO_FUNCI, 
          t1.CD_PRF_CTRA_CLI, 
          t1.CD_TIP_CTRA_CLI, 
          t1.MAT_FUNCI, 
          t1.NM_FUNCI, 
          t1.FUNCAO,
	  t1.SEXO, 
          t1.CD_ITCE_CNL_ATDT, 
          t1.CD_PRD, 
          t1.CD_MDLD, 
          t1.NM_MDLD,
          t1.VL_CPNT_RSTD, 
          t1.VL_ULT_SDO, 
          t1.COMPONENTE
      FROM WORK.INCLUI_NM_MDLD t1
	       WHERE t1.AAAAMM = &amp;amp;AnoMes;
QUIT;

proc sql; 
drop table DB2VNOT.VENDAS_INDV_MES; 
quit;

PROC SQL;
   CREATE TABLE DB2VNOT.VENDAS_INDV_MES AS 
   SELECT DISTINCT /*t1.AAAAMM,*/
          t1.NR_UNCO_CTR_OPR,
          /*t1.NR_CTR_OPR,*/ 
          /*t1.CD_CLI,*/
          t1.CD_CPNT_RSTD,
        /*t1.CD_PRF_RSTD,*/
          t1.DT_APRC, 
          t1.MES, 
          t1.ANO, 
          t1.CD_DIRETORIA, 
          t1.NM_DIRETORIA, 
	  t1.SUPER, 
          t1.NM_SUPER, 
          t1.CD_GEREV,
          t1.NM_GEREV, 
          t1.PREFIXO_FUNCI, 
          t1.NM_PREFIXO_FUNCI,
        /*t1.CD_PRF_CTRA_CLI,*/ 
          t1.CD_TIP_CTRA_CLI,
          t1.NM_FUNCI, 
          t1.FUNCAO,
	  t1.SEXO, 
          t1.CD_ITCE_CNL_ATDT,
          t1.NM_MDLD,
          t1.VL_CPNT_RSTD,
          t1.VL_ULT_SDO,
          t1.COMPONENTE
      FROM WORK.VENDAS_INDV_MES t1;
QUIT;&lt;/PRE&gt;&lt;P&gt;But, if i uncomment any of the commented columns above i get this error on DB2VNOT.VENDAS_INDV_MES :&lt;/P&gt;&lt;PRE&gt;ERROR: Error attempting to CREATE a DBMS table. ERROR: CLI execute error: [IBM][CLI Driver][DB2] SQL0104N  An unexpected token "(" 
       was found following "".  Expected tokens may include:  ", ) UNIQUE REFERENCES PRIMARY CONSTRAINT INLINE IMPLICITLY".  
       SQLSTATE=42601 .&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've also tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data DB2VNOT.VENDAS_INDV_MES;
set WORK.VENDAS_INDV_MES;
run;&lt;/PRE&gt;&lt;P&gt;An got the same error.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;None of those columns is suposed to have a &lt;STRONG&gt;UNIQUE Constraint&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 18:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921731#M20922</guid>
      <dc:creator>thiagolemosp1</dc:creator>
      <dc:date>2024-03-25T18:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921740#M20923</link>
      <description>&lt;P&gt;SAS Notes include a few similar DB2 errors relating to unexpected tokens, like this one:&amp;nbsp;&lt;A href="https://support.sas.com/kb/50/686.html" target="_blank"&gt;https://support.sas.com/kb/50/686.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The suggestion is that the underlying DDL is not well-formed. Adding this SAS option might provide more evidence: options sastrace = ',,,d' SASTRACELOC = SASLOG;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 19:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921740#M20923</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-03-25T19:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921742#M20924</link>
      <description>&lt;P&gt;I am wondering if the&amp;nbsp; "drop table" you attempt is actually removing metadata like constraints.&lt;/P&gt;
&lt;P&gt;I also would not be surprised to see table created with Select Distinct to end up with a unique constraint as that is the effect of the Distinct. You don't mention which&amp;nbsp; any of the connection details you use that might influence such a creation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you get the same error if you create a brand new never been used table name in DB2VNOT?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 19:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921742#M20924</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-25T19:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921745#M20925</link>
      <description>&lt;P&gt;How are the variables you commented out different than the one you included?&lt;/P&gt;
&lt;P&gt;Different TYPE? Different LENGTH?&amp;nbsp; Do they have different FORMATs attached to them?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 21:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921745#M20925</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-25T21:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921796#M20926</link>
      <description>&lt;P&gt;The problematic variables are all numeric and have format and informat 11. or 18. :&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Formats" style="width: 744px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94938i6C177517F4714534/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captura de tela 2024-03-26 110122 - Copia.png" alt="Formats" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Formats&lt;/span&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;For testing, i changed the code to remove all format:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data WORK.VENDAS_INDV_MES;
set WORK.VENDAS_INDV_MES;
FORMAT _all_;
INFORMAT _all_;
run;

proc sql; 
drop table DB2VNOT.VENDAS_INDV_MES; 
quit;

PROC SQL;
   CREATE TABLE DB2VNOT.VENDAS_INDV_MES AS 
   SELECT DISTINCT t1.AAAAMM,
          t1.NR_UNCO_CTR_OPR,
          t1.NR_CTR_OPR,
          t1.CD_CLI,
          t1.CD_CPNT_RSTD,
   		  t1.CD_PRF_RSTD,
          t1.DT_APRC, 
          t1.MES, 
          t1.ANO, 
          t1.CD_DIRETORIA, 
          t1.NM_DIRETORIA, 
	      t1.SUPER, 
          t1.NM_SUPER, 
          t1.CD_GEREV,
          t1.NM_GEREV, 
          t1.PREFIXO_FUNCI, 
          t1.NM_PREFIXO_FUNCI,
		  t1.CD_PRF_CTRA_CLI, 
          t1.CD_TIP_CTRA_CLI,
          t1.NM_FUNCI, 
          t1.FUNCAO,
	      t1.sexo, 
          t1.CD_ITCE_CNL_ATDT,
   		  t1.NM_MDLD,
		  t1.VL_CPNT_RSTD,
          t1.VL_ULT_SDO,
          t1.COMPONENTE
      FROM WORK.VENDAS_INDV_MES t1;
QUIT;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And it sucessfully created the table on DB2VNOT.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there anything I can do to avoid being forced to change formats?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 14:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921796#M20926</guid>
      <dc:creator>thiagolemosp1</dc:creator>
      <dc:date>2024-03-26T14:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921798#M20927</link>
      <description>&lt;P&gt;I thought about this too and tested it by removing the DISTINCT. The result was the same. Sorry for not mentioning this on the original post&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 14:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921798#M20927</guid>
      <dc:creator>thiagolemosp1</dc:creator>
      <dc:date>2024-03-26T14:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921799#M20928</link>
      <description>&lt;P&gt;This starts to feel like something you should raise with SAS Tech Support.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 14:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921799#M20928</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-26T14:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921802#M20929</link>
      <description>&lt;P&gt;SAS will normally use the format attached to a variable to guess what type to use when making a variable in a remote databases.&amp;nbsp; Something with format like 11. that displays only integers might be converted to a DECIMAL() type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;You might check if any of the values of those variables are not actually integers.&lt;/STRONG&gt;&amp;nbsp; Say 10.25.&amp;nbsp; Such a value could not be storing into a variable that only accepts integers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you can use the DBTYPE= dataset option to control the type that SAS uses to define the variable in the remote database.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921802#M20929</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-26T15:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921911#M20930</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;got an interesting idea with format 11. and integers but I can't see this really supported by the documentation&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n13gtugcxgdqstn1pooivt622n4q.htm" target="_self"&gt;LIBNAME Statement: Default DB2 Data Types for SAS Variable Formats&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I would expect for any numerical SAS variable that hasn't a date, time or datetime format attached to convert to Decimal independent of the format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now... based on the error it could be that the conversion to DB2 type&amp;nbsp;&lt;SPAN&gt;DECIMAL(&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;m,n&lt;/EM&gt;&lt;SPAN&gt;) gets wrongly created because the d component in the SAS format is "missing".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1711512049977.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94958iA47C7B4CFFBCA837/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1711512049977.png" alt="Patrick_0-1711512049977.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I still feel there is either something not as it should with the access engine or then you're not using a supported driver. That's something SAS Tech Support should be able to support you with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you already mentioned a workaround could be to just remove w.d formats. Below some sample code how you could do this programmatically.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.vendas_indv_mes;
  format num_var1 date9. num_var2 11.;
  num_var1=date();
  num_var2=45.2;
run;

%let varlist=;
proc sql noprint;
  select name into :varlist separated by ' '
  from dictionary.columns
  where 
    libname='WORK' 
    and memname='VENDAS_INDV_MES' 
    and type='num'
    and anydigit(format)=1
  ;
quit;

data work.v_vendas_indv_mes/view=work.v_vendas_indv_mes;
  set work.vendas_indv_mes;
  format &amp;amp;varlist;
run;

/** and here the SQL that loads the table into DB2     **/
/** - to just load a whole table Proc Append is faster **/ 

proc contents data=work.v_vendas_indv_mes;
run;quit;

proc print data=work.v_vendas_indv_mes;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 04:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921911#M20930</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-27T04:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Error attempting to CREATE a DBMS table.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921976#M20931</link>
      <description>Thank you so much for taking the time to help me. Im new into programing and i hope to learn quicly to start helping like you did.</description>
      <pubDate>Wed, 27 Mar 2024 14:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Error-attempting-to-CREATE-a-DBMS-table/m-p/921976#M20931</guid>
      <dc:creator>thiagolemosp1</dc:creator>
      <dc:date>2024-03-27T14:49:08Z</dc:date>
    </item>
  </channel>
</rss>

