<?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 to configure variables format null to insert in Oracle in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427514#M27542</link>
    <description>&lt;P&gt;Thank you so much!&amp;nbsp;&lt;img id="manhappy" class="emoticon emoticon-manhappy" src="https://communities.sas.com/i/smilies/16x16_man-happy.png" alt="Man Happy" title="Man Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code help me for input in Oracle database. My big problem is that &lt;U&gt;sometimes a variable can be populated in Excel and sometimes not&lt;/U&gt;, it directly interferes with the type of imported data. Using only the format and put / input was not enough, because when something did not come as expected, type hoping to convert a string to a number, but the variable was already filled with a number had a conversion error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the &lt;STRONG&gt;CATS&lt;/STRONG&gt; command helped me in this, I did not know it. Thanks a lot for the help!&lt;/P&gt;</description>
    <pubDate>Sun, 14 Jan 2018 14:14:30 GMT</pubDate>
    <dc:creator>Jr_Monteiro</dc:creator>
    <dc:date>2018-01-14T14:14:30Z</dc:date>
    <item>
      <title>How to configure variables format null to insert in Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427478#M27536</link>
      <description>&lt;P&gt;Hello guys!&lt;/P&gt;&lt;P&gt;I have a question and I need your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a PROC IMPORT of a worksheet in Excel that may or may not have records in all columns. After importing this data, I make some treatments and I need to insert the records into an Oracle table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the records after import assume any format, I need format my variables for after insert in Oracle, but as some variables are null I received this error message: "The character expression requires a character format".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="cllist"&gt;&lt;DIV class="result-dict-wrapper"&gt;&lt;DIV class="result"&gt;&lt;DIV class="text-wrap"&gt;&lt;DIV class="result-shield-container"&gt;&lt;SPAN class="translation"&gt;Would anyone have a solution for how much do I need to format columns that may or may not contain data to insert into an Oracle table?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="result-footer"&gt;&lt;DIV class="more-wrapper"&gt;&lt;DIV class="morebutton jfk-button-flat goog-inline-block goog-menu-button"&gt;&lt;DIV class="goog-inline-block goog-menu-button-outer-box"&gt;&lt;DIV class="goog-inline-block goog-menu-button-inner-box"&gt;&lt;DIV class="goog-inline-block goog-menu-button-caption"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="goog-inline-block goog-menu-button-dropdown"&gt;&amp;nbsp;This is part of my cod SAS:&lt;/DIV&gt;&lt;DIV class="goog-inline-block goog-menu-button-dropdown"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;&lt;BR /&gt;
INSERT INTO ORACLE.PROD_TABLE
SELECT COD_CUPOM_DESCONTO,
COD_CAMPANHA_DESCONTO,
NME_CUPOM_DESCONTO,
NUM_CPF_CNPJ_SEGDO FORMAT $CHAR18. ,
NUM_CEP_INI FORMAT 9.,&lt;BR /&gt;NUM_CEP_FIM FORMAT 9.,
SIG_FABRIC FORMAT $CHAR5.,
COD_TIPO_CONTR FORMAT 4.,
SIG_TIPO_DOC_COBR FORMAT $CHAR6.
FROM WORK.INSERIR_ORACLE; 
QUIT;&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>Sat, 13 Jan 2018 22:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427478#M27536</guid>
      <dc:creator>Jr_Monteiro</dc:creator>
      <dc:date>2018-01-13T22:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure variables format null to insert in Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427484#M27537</link>
      <description>&lt;P&gt;Check the variable types in WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;INSERIR_ORACLE. If COD_TIPO_CONTR&amp;nbsp;for example is character instead of numeric, then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;input(COD_TIPO_CONTR, ?&amp;nbsp;best.) as COD_TIPO_CONTR&amp;nbsp;format=4.,&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 22:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427484#M27537</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-13T22:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure variables format null to insert in Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427487#M27538</link>
      <description>&lt;P&gt;The problem is that the source is an import and when the column is filled in Excel the Guide assimilates by the fill type, otherwise it assumes the char data type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this moment your code would work fine, as it is as mine was before, but when the variable is filled in the file SAS will probably inform that I am trying to convert a number that is already number. As this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: INPUT function requires a character argument.
ERROR: Character expression requires a character format.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jan 2018 23:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427487#M27538</guid>
      <dc:creator>Jr_Monteiro</dc:creator>
      <dc:date>2018-01-13T23:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure variables format null to insert in Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427489#M27539</link>
      <description>&lt;P&gt;Sometimes, giving an explicit number format to your Excel columns will fix the problem. Otherwise you may try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;input(cats(COD_TIPO_CONTR), ?&amp;nbsp;best.) as COD_TIPO_CONTR&amp;nbsp;format=4.,&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 23:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427489#M27539</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-13T23:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure variables format null to insert in Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427490#M27540</link>
      <description>&lt;P&gt;Hello ladies!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;TLDR; In essence the issue you're encountering has little to do with nulls and more to due with a mismatch in variable types. You need to check the variable type are what Oracle expects. DateTimes are a little different so if your question concerns those, please post back.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is a more than one time procedure you'll need to build a more robust method.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is because Excel files don't enforce types in columns, but databases and SAS do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EG may have a way to enforce types as you import them in your procedure, but you need to make sure that's occurring. For example, PROC IMPORT does not provide an option to make sure the variables are character or numeric while importing the data. So you cannot guarantee that the type will be the same in each run. You are more likely to encounter this&amp;nbsp;when your data set has nulls, because of how SAS imports data. It goes through and has to guess at a type, but the number of records it scans before guessing a type may be too low. You can look at the GUESSINGROWS system option, but that's more complex for an Excel file. &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need to build a step into your process that will ensure the data types are correct. You may also be mixing up types and formats/informats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Type - controls how variable is stored in the data set;&amp;nbsp;SAS has two types, character and numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Format - controls how the variable is displayed.&lt;/P&gt;
&lt;P&gt;Informat - controls how the variable is read in. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS doesn't allow type conversion on the fly, so you need to create new variables that have the type and format you need. You can do this within the PROC SQL step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert to a character:&lt;/P&gt;
&lt;P&gt;PUT(variableName, formatOutput)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert toa number:&lt;/P&gt;
&lt;P&gt;INPUT(variableName,&amp;nbsp;formatInput)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie convert a number to a character variable within your SQL step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;put(NUM_CPF_CNPJ_SEGDO, $char18.) as NUM_CPF_CNPG_SEGDO_n &lt;SPAN class="token procnames"&gt;FORMAT&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;CHAR18&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;,&lt;BR /&gt;..,&lt;BR /&gt;input(cod_TIP_CONTR, 8.) as COD_TIP_CONTR_c FORMAT 8.,&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 00:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427490#M27540</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-14T00:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure variables format null to insert in Oracle</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427514#M27542</link>
      <description>&lt;P&gt;Thank you so much!&amp;nbsp;&lt;img id="manhappy" class="emoticon emoticon-manhappy" src="https://communities.sas.com/i/smilies/16x16_man-happy.png" alt="Man Happy" title="Man Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code help me for input in Oracle database. My big problem is that &lt;U&gt;sometimes a variable can be populated in Excel and sometimes not&lt;/U&gt;, it directly interferes with the type of imported data. Using only the format and put / input was not enough, because when something did not come as expected, type hoping to convert a string to a number, but the variable was already filled with a number had a conversion error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the &lt;STRONG&gt;CATS&lt;/STRONG&gt; command helped me in this, I did not know it. Thanks a lot for the help!&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 14:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-configure-variables-format-null-to-insert-in-Oracle/m-p/427514#M27542</guid>
      <dc:creator>Jr_Monteiro</dc:creator>
      <dc:date>2018-01-14T14:14:30Z</dc:date>
    </item>
  </channel>
</rss>

