<?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: X command with parameters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653217#M196208</link>
    <description>&lt;P&gt;Sounds like you just need to make sure you quote things properly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's look at your examples one by one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X ' /home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' ' ; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So your have given X a series of quoted text and unquoted text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;' /home/test/shellscript.sh USER PWD FORMAT '
TEXT
' ESCAPECHAR '
\
' CTRLCHARS '
YES
' '&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And some of these of the unquoted text is coming immediately after the quoted text which will cause SAS to think you want a special literal, like a date or time value.&lt;/P&gt;
&lt;P&gt;In the second one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X ' /home/test/shellscript.sh "USER" "PWD" "FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' " ';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you have added quotes around the outside and changed some of the quotes in string, but you did change or double all of quotes in the middle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last one looks valid.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X "/home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' ";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But perhaps the issue is that the script does not work on the machine where SAS is running? Or for the userid that is actually running the SAS code?&lt;/P&gt;
&lt;P&gt;Normally I use a data step to run code so I can read back the messages that the operating system command generates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "/home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' " pipe ;
  input ;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also add 2&amp;gt;&amp;amp;1 to the end of command to make sure that error message from the log are directed back to SAS instead of appearing on the terminal of the process that launched SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 13:23:33 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-06-04T13:23:33Z</dc:date>
    <item>
      <title>X command with parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653093#M196151</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have written a shell script to call from SAS via X command. The shell script has totally&amp;nbsp;3 parameters that I have to pass.&lt;/P&gt;
&lt;P&gt;I have a pass one parameters as FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' along with other two parameters. Example as like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;X ' /home/test/shellscript.sh&amp;nbsp;USER&amp;nbsp;PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES'&amp;nbsp;' ;&amp;nbsp; but ended up in failure. Even I tried with double quotes as like below&lt;/P&gt;
&lt;P&gt;X ' /home/test/shellscript.sh&amp;nbsp;"USER"&amp;nbsp;"PWD" "FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES'&amp;nbsp;" ';&lt;/P&gt;
&lt;P&gt;X "/home/test/shellscript.sh&amp;nbsp;USER&amp;nbsp;PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES'&amp;nbsp;";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No luck on the SAS code. Please help me to resolve this. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 07:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653093#M196151</guid>
      <dc:creator>helannivas88</dc:creator>
      <dc:date>2020-06-04T07:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: X command with parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653098#M196152</link>
      <description>&lt;P&gt;First, build safeguards into your script so that it reports a wrong call.&lt;/P&gt;
&lt;P&gt;Next, make sure that you get it working from a commandline.&lt;/P&gt;
&lt;P&gt;Then, call your script with a filename pipe:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename oscmd pipe "/home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES'  2&amp;gt;&amp;amp;1";

data _null_;
infile oscmd;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and inspect the SAS log for messages returned from the command.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 07:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653098#M196152</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-04T07:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: X command with parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653156#M196183</link>
      <description>&lt;P&gt;use -SET in shell file to pass parameters.&lt;BR /&gt;-sysin ...... -set x 'abc' -set n 10 ............&lt;BR /&gt;&lt;BR /&gt;in sas code use %sysget() to get parameter value.&lt;BR /&gt;%let x=%sysget(x);&lt;BR /&gt;%let n=%sysget(n);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; wrote a blog about it .&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 10:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653156#M196183</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-05T10:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: X command with parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653217#M196208</link>
      <description>&lt;P&gt;Sounds like you just need to make sure you quote things properly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's look at your examples one by one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X ' /home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' ' ; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So your have given X a series of quoted text and unquoted text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;' /home/test/shellscript.sh USER PWD FORMAT '
TEXT
' ESCAPECHAR '
\
' CTRLCHARS '
YES
' '&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And some of these of the unquoted text is coming immediately after the quoted text which will cause SAS to think you want a special literal, like a date or time value.&lt;/P&gt;
&lt;P&gt;In the second one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X ' /home/test/shellscript.sh "USER" "PWD" "FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' " ';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you have added quotes around the outside and changed some of the quotes in string, but you did change or double all of quotes in the middle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The last one looks valid.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X "/home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' ";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But perhaps the issue is that the script does not work on the machine where SAS is running? Or for the userid that is actually running the SAS code?&lt;/P&gt;
&lt;P&gt;Normally I use a data step to run code so I can read back the messages that the operating system command generates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "/home/test/shellscript.sh USER PWD FORMAT 'TEXT' ESCAPECHAR '\' CTRLCHARS 'YES' " pipe ;
  input ;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also add 2&amp;gt;&amp;amp;1 to the end of command to make sure that error message from the log are directed back to SAS instead of appearing on the terminal of the process that launched SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 13:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653217#M196208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-04T13:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: X command with parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653558#M196325</link>
      <description>&lt;P&gt;KSharp is referring to &lt;A href="https://blogs.sas.com/content/iml/2015/03/16/pass-params-sysget.html" target="_self"&gt;"How to pass parameters to a SAS program."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 11:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-command-with-parameters/m-p/653558#M196325</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-06-05T11:17:59Z</dc:date>
    </item>
  </channel>
</rss>

