<?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 writing dataset with several special column names to SQL server in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753079#M237307</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to write a dataset to a SQL server table, though I have several columns with special characters (because of a transpose). Is it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My libname statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname NB3DS_01 SQLSVR  READBUFF=32000  INSERTBUFF=32000  DELETE_MULT_ROWS=YES  UPDATE_MULT_ROWS=YES  Datasrc=BISQL1  SCHEMA=NB3DS_01  AUTHDOMAIN="Auth_BISQL1" ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Knipsel.PNG" style="width: 424px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61095i0AB021EC01D8188F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Knipsel.PNG" alt="Knipsel.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;proc append base=NB3DS_01.MDM_PQ_&amp;amp;file_type._&amp;amp;current_month data=temp_transp_&amp;amp;i. force;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The error:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ERROR: During insert: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Invalid object name &lt;BR /&gt;'NB3DS_01.MDM_PQ_reg_202107'. Error in parameter 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I would create the first variable in SQL server management studio, he put's brackets around the column name. How can I force this with SAS?&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="Knipsel2.PNG" style="width: 192px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61096i5EFDB84479FD92D9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Knipsel2.PNG" alt="Knipsel2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jul 2021 07:52:14 GMT</pubDate>
    <dc:creator>Filipvdr</dc:creator>
    <dc:date>2021-07-09T07:52:14Z</dc:date>
    <item>
      <title>writing dataset with several special column names to SQL server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753079#M237307</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to write a dataset to a SQL server table, though I have several columns with special characters (because of a transpose). Is it possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My libname statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname NB3DS_01 SQLSVR  READBUFF=32000  INSERTBUFF=32000  DELETE_MULT_ROWS=YES  UPDATE_MULT_ROWS=YES  Datasrc=BISQL1  SCHEMA=NB3DS_01  AUTHDOMAIN="Auth_BISQL1" ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Knipsel.PNG" style="width: 424px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61095i0AB021EC01D8188F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Knipsel.PNG" alt="Knipsel.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;proc append base=NB3DS_01.MDM_PQ_&amp;amp;file_type._&amp;amp;current_month data=temp_transp_&amp;amp;i. force;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The error:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ERROR: During insert: [SAS][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Invalid object name &lt;BR /&gt;'NB3DS_01.MDM_PQ_reg_202107'. Error in parameter 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I would create the first variable in SQL server management studio, he put's brackets around the column name. How can I force this with SAS?&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="Knipsel2.PNG" style="width: 192px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61096i5EFDB84479FD92D9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Knipsel2.PNG" alt="Knipsel2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 07:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753079#M237307</guid>
      <dc:creator>Filipvdr</dc:creator>
      <dc:date>2021-07-09T07:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: writing dataset with several special column names to SQL server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753121#M237329</link>
      <description>Check &lt;BR /&gt;PRESERVE_COL_NAMES= and PRESERVE_TAB_NAMES= LIBNAME options:</description>
      <pubDate>Fri, 09 Jul 2021 12:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753121#M237329</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-07-09T12:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: writing dataset with several special column names to SQL server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753122#M237330</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;in SAS you have to adhere to &lt;A href="https://v8doc.sas.com/sashtml/lgref/z1031056.htm" target="_blank" rel="noopener"&gt;the Rules for Most SAS Names&lt;/A&gt;&amp;nbsp;when creating a dataset&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Special characters, except for the underscore, are not allowed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After a proc import for example from an excel file by using&amp;nbsp;options validvarname=any; you could have datasets not respecting these rules.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To further proceed, the solution is to rename the variables like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT out=test1 &amp;lt;..&amp;gt;RUN;
data test2;
 set test1;
rename   'Some strange variable name'n=var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;It's not clear to me if you can write out these special characters to a SQL server table, but it might be worth to try 'varname'n&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 12:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-dataset-with-several-special-column-names-to-SQL-server/m-p/753122#M237330</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2021-07-09T12:35:46Z</dc:date>
    </item>
  </channel>
</rss>

