<?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: Executing SAS Code from PowerShell in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/36319#M256236</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm only just starting to investigate this same thing, so my answer is not only belated (I only just saw your post) but half-baked as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said that, this works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;pushd "$env:userprofile\My Documents\My SAS Programs"

$cmd="C:\Program Files\SAS\SASFoundation\9.2\sas.exe"
$cfg="C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG"
$pgm="test1.sas"

cmd /c " ""$cmd"" -config ""$cfg"" -sysin ""$pgm"" "

# I also tried all of these, since I do not want to use cmd /c if at all possible
# But, they do not properly set the $LastExitCode from SAS

# Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait 
# Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait -PassThru
# Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait -NoNewWindow

"LastExitCode=$LastExitCode"

popd
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also posted here to try and get further help:&amp;nbsp; &lt;A href="http://www.powershellcommunity.org/Forums/tabid/54/aft/7999/Default.aspx"&gt;http://www.powershellcommunity.org/Forums/tabid/54/aft/7999/Default.aspx&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But like I said, the above works for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Feb 2012 04:04:33 GMT</pubDate>
    <dc:creator>ScottBass</dc:creator>
    <dc:date>2012-02-17T04:04:33Z</dc:date>
    <item>
      <title>Executing SAS Code from PowerShell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/36318#M256235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to executing SAS code in batch mode using Powershell to kick it off.&amp;nbsp; Within the powershell code we assign the code to a variable call $SAS_APPLICATION_LOCATION and the code we are trying to assign to it as shown which the version that is use in a batch file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin "E:\Propagator Import\Export PACS test data.sas" -fullstimer -ALTLOG "E:\codeshare\"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are using the following to run the execute this job:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ApplicationOutput = cmd /c $SAS_APPLICATION_LOCATION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We could not get it to work but we did get it work using Ping with one of our server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do anybody have any experience running SAS code in batch mode using PowerShell?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help in this matter. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 16:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/36318#M256235</guid>
      <dc:creator>Bridget53</dc:creator>
      <dc:date>2012-01-23T16:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Executing SAS Code from PowerShell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/36319#M256236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm only just starting to investigate this same thing, so my answer is not only belated (I only just saw your post) but half-baked as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said that, this works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;pushd "$env:userprofile\My Documents\My SAS Programs"

$cmd="C:\Program Files\SAS\SASFoundation\9.2\sas.exe"
$cfg="C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG"
$pgm="test1.sas"

cmd /c " ""$cmd"" -config ""$cfg"" -sysin ""$pgm"" "

# I also tried all of these, since I do not want to use cmd /c if at all possible
# But, they do not properly set the $LastExitCode from SAS

# Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait 
# Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait -PassThru
# Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait -NoNewWindow

"LastExitCode=$LastExitCode"

popd
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also posted here to try and get further help:&amp;nbsp; &lt;A href="http://www.powershellcommunity.org/Forums/tabid/54/aft/7999/Default.aspx"&gt;http://www.powershellcommunity.org/Forums/tabid/54/aft/7999/Default.aspx&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But like I said, the above works for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 04:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/36319#M256236</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2012-02-17T04:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Executing SAS Code from PowerShell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/605880#M256237</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;P&gt;It is good to know we have to add Start-Process before call sas.exe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did anyone try call SAS EG Project from PowerShell?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried, but it only pops up EG window, not execute the Project Flow,&lt;/P&gt;&lt;P&gt;wondering what is the trick(or option) I have to give here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lynn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Executing-SAS-Code-from-PowerShell/m-p/605880#M256237</guid>
      <dc:creator>ljin0599</dc:creator>
      <dc:date>2019-11-20T18:43:48Z</dc:date>
    </item>
  </channel>
</rss>

