<?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: Scheduled job is failing probably because of the Warning message WARNING: Character expression w in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887982#M350826</link>
    <description>&lt;P&gt;I consider it best practice to fix the cause of the warning rather than fixing the symptoms. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
insert into server.final (Date, Name, Type, Full_Comments)
select
     a.Date,
     a.Name,
     a.Type as Type length = 15,
     a.Full_Comments
from work.import a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Aug 2023 22:46:27 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2023-08-04T22:46:27Z</dc:date>
    <item>
      <title>Scheduled job is failing probably because of the Warning message WARNING: Character expression will</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887897#M350794</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a scheduled job that keeps on failing.&lt;/P&gt;&lt;P&gt;The SAS runs fine except for a it gets WARNING: Character expression will be truncated when assigned to character column Type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was told by our support to configure the scheduler to look for exit code 1 since the SAS tables are being updated as expected. However, if I change this to exit code 1, it won’t be able to detect if the code has an error or if it failed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Asking the scheduler to look for Exit Code = 0, fails because I have a Warning message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;My questions are:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;How do I get rid of WARNING: Character expression will be truncated when assigned to character column Type?&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;The Type column in the server.final has Type=Char, Len=15, Format = $15., Informat = $15.&lt;/LI&gt;&lt;LI&gt;I tried to do something like substr(Type,1,15) length=15 and I also tried altering the character type before inserting to align the format/informat but it didn’t help – I got the idea from &lt;A href="https://stackoverflow.com/questions/30468664/getting-a-warning-when-inserting-a-row-using-proc-sql" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;How do I know what is the exit code of my sas program?&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;I added %put &amp;amp;=syscc in the end of the program I got code 1012 but I don’t know if that’s the exit code&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my sas code, it’s very simple but I noticed that the job is failing when add the insert code.&lt;/P&gt;&lt;P&gt;Really appreciate your help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc import out=work.import
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datafile='directory/a.xls'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms=xls replace ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;getnames=yes;
run;

proc sql;
insert into server.final (Date, Name, Type, Full_Comments)
select
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.Date,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.Name,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.Type,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a.Full_Comments
from work.import a;
quit;
%put &amp;amp;=syscc;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 15:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887897#M350794</guid>
      <dc:creator>couthelle</dc:creator>
      <dc:date>2023-08-04T15:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job is failing probably because of the Warning message WARNING: Character expression w</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887973#M350822</link>
      <description>&lt;P&gt;With regard to your 2nd question (exit code) ... I would use &amp;amp;syserr.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro Language Reference&lt;BR /&gt;&lt;STRONG&gt;SYSCC&lt;/STRONG&gt; Automatic Macro Variable&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p11nt7mv7k9hl4n1x9zwkralgq1b.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p11nt7mv7k9hl4n1x9zwkralgq1b.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro Language Reference&lt;BR /&gt;&lt;STRONG&gt;SYSERR&lt;/STRONG&gt; Automatic Macro Variable&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n1wrevo4roqsnxn1fbd9yezxvv9k.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n1wrevo4roqsnxn1fbd9yezxvv9k.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set notfound;
run;

proc options option=errorcheck; run;

%put &amp;amp;=Syscc;
%put &amp;amp;=SysErr; 
%put &amp;amp;=SysWarningText; 
%put &amp;amp;=SysErrorText;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 21:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887973#M350822</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-08-04T21:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job is failing probably because of the Warning message WARNING: Character expression w</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887982#M350826</link>
      <description>&lt;P&gt;I consider it best practice to fix the cause of the warning rather than fixing the symptoms. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
insert into server.final (Date, Name, Type, Full_Comments)
select
     a.Date,
     a.Name,
     a.Type as Type length = 15,
     a.Full_Comments
from work.import a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Aug 2023 22:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887982#M350826</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-08-04T22:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job is failing probably because of the Warning message WARNING: Character expression w</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887985#M350827</link>
      <description>&lt;P&gt;I'm very much for an approach where SAS code shouldn't return warnings. I believe a warning creates an exit code 1 but an error exit code 2. If you would allow for exit code 1 you still would capture error conditions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel is just a bad data source for any sort of ETL style process. You can't rely on getting stable results/table structures using Proc Import. The result will always depend on the specific version of the Excel and what data it contains.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My first question would be: Why do you get a variable with a length longer than expected by your target table? Proc Import creates the length of a character variable using the longest string it finds in the data so likely the Warning is an indication for actual string truncation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also important: With the xls engine you need to define guessingrows=max as else string truncation can already occur during import with Proc Import.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 23:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887985#M350827</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-08-04T23:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job is failing probably because of the Warning message WARNING: Character expression w</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887995#M350831</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;thank you very much, really appreciate the advice!&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 01:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887995#M350831</guid>
      <dc:creator>couthelle</dc:creator>
      <dc:date>2023-08-05T01:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job is failing probably because of the Warning message WARNING: Character expression w</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887996#M350832</link>
      <description>&lt;P&gt;Thanks a bunch&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;this is exactly what I'm looking for!&lt;/P&gt;&lt;PRE&gt;%put &amp;amp;=SysErr; &lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Aug 2023 02:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887996#M350832</guid>
      <dc:creator>couthelle</dc:creator>
      <dc:date>2023-08-05T02:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scheduled job is failing probably because of the Warning message WARNING: Character expression w</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887997#M350833</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;I tried to configure the scheduler to look for exit code = 1 after the code ran after deliberately screwing up my code i.e missing ";" but the scheduler didn't detect that error and still ended with Success status.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for why I'm using excel, this is actually someone else's task, I'm just trying to automate it without really changing the work file of that person because he didn't know how to code in SAS. Adding&amp;nbsp;&lt;SPAN&gt;guessingrows=max&amp;nbsp;is really helpful, I should have thought of that right away! But really appreciate that feedback!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 02:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scheduled-job-is-failing-probably-because-of-the-Warning-message/m-p/887997#M350833</guid>
      <dc:creator>couthelle</dc:creator>
      <dc:date>2023-08-05T02:11:18Z</dc:date>
    </item>
  </channel>
</rss>

