<?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: Adding network file path with spaces to X command in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290922#M59816</link>
    <description>&lt;P&gt;Personally, I would find a bit easier to create the whole string in a data set variable, and perhaps execute it via CALL SYSTEM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See also another thread with a similar issue, and&amp;nbsp;various suggestions....:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/resolving-macro-variable-inside-single-quotes/td-p/67294" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/resolving-macro-variable-inside-single-quotes/td-p/67294&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2016 09:04:06 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-08-11T09:04:06Z</dc:date>
    <item>
      <title>Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290918#M59814</link>
      <description>&lt;P&gt;I have to send some parameters to an external .exe using the x command. Because I may be sending parameters that are fed from&amp;nbsp;macro variables, and may also contain single quotes, I enclose the entire&amp;nbsp;string within a quote statement. (Some of the parameters may contain spaces, which is why they are enclosed in double quotes):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x %sysfunc(quote(
c:\windows\temp\myapplication.exe /loginandget
"parameter 1"
parameter2
&amp;amp;Param3var.
"parameter 4"
));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works correctly as intended. The problem is that I'd like to move &lt;I&gt;myapplication.exe&lt;/I&gt; to a network filepath that contains spaces. I've tried various combinations of double quotes, moving the &lt;I&gt;%sysfunc(quote&lt;/I&gt; to different places in the string, adding &lt;I&gt;%STR("")&lt;/I&gt; and nothing seems to work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x %sysfunc(quote(
\\my share\my subfolder\myapplication.exe /loginandget
"parameter 1"
parameter2
&amp;amp;Param3var.
"parameter 4"
));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When testing, I've replaced &lt;I&gt;x&lt;/I&gt; with &lt;I&gt;%let x =&lt;/I&gt; and then added a &lt;I&gt;%put x;&lt;/I&gt; at the bottom to see how SAS parses the string, and results that look like they &lt;I&gt;should&lt;/I&gt; work, don't when I change the code back to the x command!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice gratefully received. Many thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 08:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290918#M59814</guid>
      <dc:creator>basinbasin</dc:creator>
      <dc:date>2016-08-11T08:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290920#M59815</link>
      <description>&lt;P&gt;Build the whole command string in a &lt;FONT face="courier new,courier"&gt;data _null_&lt;/FONT&gt; step and use &lt;FONT face="courier new,courier"&gt;call system()&lt;/FONT&gt; to execute it.&lt;/P&gt;
&lt;P&gt;That way you can run the data step repeatedly during testing (replacing the &lt;FONT face="courier new,courier"&gt;call system()&lt;/FONT&gt; with a &lt;FONT face="courier new,courier"&gt;put&lt;/FONT&gt; or have the string written to a dataset), build the string element-by-element and check at every stage if you did it correctly.&lt;/P&gt;
&lt;P&gt;Once the result is as wanted, implement the &lt;FONT face="courier new,courier"&gt;call system()&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's much easier to deal with multiple (and different) quotes inside a data step, where you can use single quotes to build a string containing doubles, and vice versa, and then concatenate it all together. Don't forget to use &lt;FONT face="courier new,courier"&gt;length&lt;/FONT&gt; so that your string variables are long enough.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 09:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290920#M59815</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-11T09:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290922#M59816</link>
      <description>&lt;P&gt;Personally, I would find a bit easier to create the whole string in a data set variable, and perhaps execute it via CALL SYSTEM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See also another thread with a similar issue, and&amp;nbsp;various suggestions....:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/resolving-macro-variable-inside-single-quotes/td-p/67294" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/resolving-macro-variable-inside-single-quotes/td-p/67294&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 09:04:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290922#M59816</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-11T09:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290923#M59817</link>
      <description>&lt;P&gt;You need to also put the .exe command in quotes&lt;/P&gt;&lt;P&gt;"\\my share\my subfolder\myapplication.exe"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not tested, but it should work.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 09:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290923#M59817</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-11T09:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290926#M59818</link>
      <description>&lt;P&gt;Out of interest, what is this "application" to do? &amp;nbsp;In my experience I have never seen a need to call external programs from within a SAS session - its complicated and never necessary. &amp;nbsp;By loginandget I assume this is accessing a system and retrieving some information? &amp;nbsp;If so then address the process of data transfer - how does your other system deliver data, can it be scheduled to dump data to specified location, which your SAS program can access, could you directly interface to the data in that system etc. &amp;nbsp;Many ways of doing things. &amp;nbsp;The reason being is 5 or 6 years down the line when you have moved on, someone else will look at that bit of code and an exe file which has stopped working and then have to try to sort it all out. &amp;nbsp;Keep it as simple as possible, use the two systems you already have - data source and your program - don't add in additional components.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 09:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/290926#M59818</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-11T09:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/291213#M59866</link>
      <description>&lt;P&gt;Thanks for your help everyone. I liked&amp;nbsp;the idea of building and testing the output in a data _null_ statement, and then using call execute to call it. However, I still couldn't get it to work. Although my path was surrounded in double quotes (or double double quotes) in the sample sent to the log, I still ended up with "invalid path" errors. Either that, or it was obvious that the path was being truncated at the first space in the path name despite being enclosed in quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end, I ended up "cheating" and converted the file path to my exe to&amp;nbsp;DOS format in my code. So:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;my share&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;my subfolder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;myapplication&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;ex&lt;/SPAN&gt;e becomes \\MYSHAR~1\MYSUBF~1\myapplication.exe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So no need for quotes, and it works as intended. The code I've written is sort of sample code which discusses using X, Filename... pipe and rc=system(...) (but not call execute annoyingly) so I also needed a solution that didn't require bespoke recoding for each call method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I'd love to get the source data from a local database, but the number of articles and search results for Filename... URL and using cURL with SAS suggests that I'm not the only one having to "hack" getting web-based data, which is what the application does.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 10:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/291213#M59866</guid>
      <dc:creator>basinbasin</dc:creator>
      <dc:date>2016-08-12T10:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/291222#M59867</link>
      <description>&lt;P&gt;Well, if your access a web database, and you can't directly access it (say with proc http), then I would seperate the processes. &amp;nbsp;Process 1 would be the connecting to a database, downloading data to a csv file. &amp;nbsp;End of process - make sure all that works, and is validated and schedule it. &amp;nbsp;Then a seperate process, you SAS program, would load that CSV. &amp;nbsp;No need to run one from the other.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 11:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/291222#M59867</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-12T11:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/291234#M59868</link>
      <description>&lt;P&gt;It's the old argument, really, of flexibility vs robustness, I guess.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We use a vendor's external website, which we log into. They actually have a&amp;nbsp;webpage on their site where you can type SQL into the webpage, hit the button, and the results are returned in an HTML table, or flat file, or excel spreadsheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the flexibility is that we can manipulate internal data&amp;nbsp;using SAS, and then utilise that data to use within the SQL that we then send using the external application into the webtool.&amp;nbsp;As a really simple example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;

SELECT DISTINCT "'"||trim(CITY)||"'"
 INTO :city
 FROM some_local_table (Obs=1);
 QUIT;

 %put &amp;amp;city.;

x %sysfunc(quote(
\\my share\my subfolder\myapplication.exe /loginandget
"parameter 1"
parameter2
&amp;amp;Param3var.
"select col1, col2 from vendors_remote_table where city=&amp;amp;city."
));&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;Yes it's a horrible hack, but needs must.... The vendor also does send us overnight batch files which are uploaded into a SAS Server, but lately, this process fails as often as it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But as you say, if we're always going to be getting the same data back from the vendor's site, no reason why we can't schedule the application to run outside of SAS, and save the output somewhere, and then schedule a SAS job to pick up that data and do things with it.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 12:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/291234#M59868</guid>
      <dc:creator>basinbasin</dc:creator>
      <dc:date>2016-08-12T12:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding network file path with spaces to X command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/409335#M67167</link>
      <description>&lt;P&gt;Try to use single quotes around double quotes (or double quotes around single quotes like for this x command:&lt;/P&gt;
&lt;P&gt;x "D:\Bla Bla\OneDrive\My OneDrive Folder\Bla analysis\My bla analysis results.xlsx";&lt;/P&gt;&lt;P&gt;: does not work&lt;/P&gt;&lt;P&gt;x '"D:\Bla Bla\OneDrive\My OneDrive Folder\Bla analysis\My bla analysis results.xlsx"';&lt;/P&gt;&lt;P&gt;: works&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 02:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-network-file-path-with-spaces-to-X-command/m-p/409335#M67167</guid>
      <dc:creator>kleinhev</dc:creator>
      <dc:date>2017-11-01T02:04:16Z</dc:date>
    </item>
  </channel>
</rss>

