<?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: Pass datstep variable to X command in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415737#M102012</link>
    <description>Hi Shumel. Ok, I think my post is not clear. jobname is a variable which contains list of jobnames (like J_ABC,J_DEF etc) These are located under a mentioned location and extension is sh.</description>
    <pubDate>Thu, 23 Nov 2017 05:50:11 GMT</pubDate>
    <dc:creator>Sandy10</dc:creator>
    <dc:date>2017-11-23T05:50:11Z</dc:date>
    <item>
      <title>Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415732#M102008</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below is&amp;nbsp;the&amp;nbsp;code i am using . I want to execute a job using&amp;nbsp;X command in a datastep.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Path and Extn are macro variables. jobname is a datastep variable(from check dataset)&lt;/P&gt;&lt;P&gt;&amp;nbsp;jobname is a variable which contains list of jobnames (like J_ABC,J_DEF etc) These are located under a mentioned location and extension is sh.Purpose is to execute those jobs using X command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set check;&lt;/P&gt;&lt;P&gt;%let path=/app/scripts_p2/jobs;&lt;BR /&gt;%let extn=sh;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;x "&amp;amp;path/jobname.&amp;amp;extn";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kindly advise&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Its getting retrieved as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/bin/ksh: /app/scripts_p2/jobs/jobname.sh: not found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;BR /&gt;Sandhya S&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 05:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415732#M102008</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2017-11-23T05:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415735#M102010</link>
      <description>&lt;P&gt;1) Have checked that&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;/app/scripts_p2/jobs/jobname.sh&lt;/SPAN&gt;&lt;/STRONG&gt; file realy exist ?&lt;/P&gt;
&lt;P&gt;2) Is the file executable ? - check unix permissions: user's and group's permission.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 05:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415735#M102010</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-11-23T05:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415737#M102012</link>
      <description>Hi Shumel. Ok, I think my post is not clear. jobname is a variable which contains list of jobnames (like J_ABC,J_DEF etc) These are located under a mentioned location and extension is sh.</description>
      <pubDate>Thu, 23 Nov 2017 05:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415737#M102012</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2017-11-23T05:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415739#M102014</link>
      <description>&lt;P&gt;Then of course it cannot work as the result has unix sytax error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;/app/scripts_p2/jobs/&amp;nbsp;J_ABC,J_DEF.sh&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to execute each job separatly.&lt;/P&gt;
&lt;P&gt;Use SCAN funtion in a loop and execute the jobs one by one.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 05:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415739#M102014</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-11-23T05:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415742#M102015</link>
      <description>&lt;P&gt;Within a data step, Build a string variable that has the code you want to execute, not Including the X. You can use the CATT function with macro variables and data step variables. Then use CALL SYSTEM to have it executed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data demo;
Set SASHELP.class;
Str = catt('string1', ....., “&amp;amp;path1.”, job);
*Call system(Str);
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 06:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415742#M102015</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-23T06:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415743#M102016</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/175274"&gt;@Sandy10&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;Hi &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below is&amp;nbsp;the&amp;nbsp;code i am using . I want to execute a job using&amp;nbsp;X command in a datastep.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Path and Extn are macro variables. jobname is a datastep variable(from check dataset)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;jobname is a variable which contains list of jobnames (like J_ABC,J_DEF etc) These are located under a mentioned location and extension is sh.Purpose is to execute those jobs using X command.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set check;&lt;/P&gt;
&lt;P&gt;%let path=/app/scripts_p2/jobs;&lt;BR /&gt;%let extn=sh;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;x "&amp;amp;path/jobname.&amp;amp;extn";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Kindly advise&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its getting retrieved as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/bin/ksh: /app/scripts_p2/jobs/jobname.sh: not found&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;BR /&gt;Sandhya S&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 06:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415743#M102016</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-23T06:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415756#M102020</link>
      <description>&lt;P&gt;The X-statement is a "global" command that is not part of the datastep. You cannot get this to work. To do this you have to use the system function or Call routine.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Like&amp;nbsp;&amp;nbsp; rc = system( cats("&amp;amp;path/",jobname,".&amp;amp;extn") );&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 07:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415756#M102020</guid>
      <dc:creator>PSNn</dc:creator>
      <dc:date>2017-11-23T07:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Pass datstep variable to X command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415779#M102032</link>
      <description>&lt;P&gt;This code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

set check;

%let path=/app/scripts_p2/jobs;
%let extn=sh;

 

 x "&amp;amp;path/jobname.&amp;amp;extn";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;cant't work because X is a global statement that is executed as soon as it is encountered in the program text, so it will ALWAYS resolve to&lt;/P&gt;
&lt;PRE&gt;x "/app/scripts_p2/jobs/jobname.sh";&lt;/PRE&gt;
&lt;P&gt;with "jobname" being a literal. Use call system() instead, which is a data step subroutine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=/app/scripts_p2/jobs;
%let extn=sh;

data _null_;
set check;
call system("&amp;amp;path./" !! trim(jobname !! ".&amp;amp;extn.");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also note that it makes your code easier to grok when the macro statements are placed &lt;U&gt;before&lt;/U&gt; the data step, because that is the order in which they are executed anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 09:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-datstep-variable-to-X-command/m-p/415779#M102032</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-23T09:11:20Z</dc:date>
    </item>
  </channel>
</rss>

