<?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 Get UNC path for a mapped drive in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483337#M125331</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to get UNC path for a mapped drive as different users have their HOME drive on different servers.&lt;/P&gt;
&lt;P&gt;I use the getUNC macro from the really good paper “The Path, The Whole Path, And Nothing But the Path, So Help Me Windows” by Arthur L. Carpenter (&lt;A href="http://www2.sas.com/proceedings/forum2008/023-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/023-2008.pdf&lt;/A&gt;).&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;%MACRO getUNC ;
DATA _NULL_;
length input_dir $200 output_dir $200;
* The input directory can only be a drive letter + colon ONLY e.g. j: ;
input_dir = 'h:';
output_dir = ' ';
output_len = 200;
call module("WNetGetConnectionA", input_dir, output_dir, output_len);
call symputx('dir',input_dir,'l');
call symputx('path',output_dir,'l');
RUN;
%put drive letter is &amp;amp;dir;
%put path is &amp;amp;path;
%MEND getunc;

%getunc;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But get following error:&lt;/P&gt;
&lt;P&gt;NOTE: Invalid argument to function MODULE('WNetGetConne'[12 of 18 characters shown],'h:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '[12 of 200 characters shown],'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '[12 of 200 characters shown],200) at line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 column 186.&lt;/P&gt;
&lt;P&gt;input_dir=h: output_dir=&amp;nbsp; output_len=200 _ERROR_=1 _N_=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am on Window 10 and use SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone see what is going wrong?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Aug 2018 10:34:57 GMT</pubDate>
    <dc:creator>alr</dc:creator>
    <dc:date>2018-08-02T10:34:57Z</dc:date>
    <item>
      <title>Get UNC path for a mapped drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483337#M125331</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to get UNC path for a mapped drive as different users have their HOME drive on different servers.&lt;/P&gt;
&lt;P&gt;I use the getUNC macro from the really good paper “The Path, The Whole Path, And Nothing But the Path, So Help Me Windows” by Arthur L. Carpenter (&lt;A href="http://www2.sas.com/proceedings/forum2008/023-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/023-2008.pdf&lt;/A&gt;).&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;%MACRO getUNC ;
DATA _NULL_;
length input_dir $200 output_dir $200;
* The input directory can only be a drive letter + colon ONLY e.g. j: ;
input_dir = 'h:';
output_dir = ' ';
output_len = 200;
call module("WNetGetConnectionA", input_dir, output_dir, output_len);
call symputx('dir',input_dir,'l');
call symputx('path',output_dir,'l');
RUN;
%put drive letter is &amp;amp;dir;
%put path is &amp;amp;path;
%MEND getunc;

%getunc;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But get following error:&lt;/P&gt;
&lt;P&gt;NOTE: Invalid argument to function MODULE('WNetGetConne'[12 of 18 characters shown],'h:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '[12 of 200 characters shown],'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '[12 of 200 characters shown],200) at line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 column 186.&lt;/P&gt;
&lt;P&gt;input_dir=h: output_dir=&amp;nbsp; output_len=200 _ERROR_=1 _N_=1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am on Window 10 and use SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone see what is going wrong?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 10:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483337#M125331</guid>
      <dc:creator>alr</dc:creator>
      <dc:date>2018-08-02T10:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Get UNC path for a mapped drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483341#M125332</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to copy/paste the code in the document and the problem occurred as you described.&lt;/P&gt;
&lt;P&gt;It appeared that the copy/paste has concatenated two arguments of the routine instruction :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STACKPOP=CALLEDRETURNS=LONG&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STACKPOP=CALLED RETURNS=LONG&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding a space solved the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 10:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483341#M125332</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-08-02T10:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get UNC path for a mapped drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483347#M125334</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 11:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483347#M125334</guid>
      <dc:creator>alr</dc:creator>
      <dc:date>2018-08-02T11:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get UNC path for a mapped drive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483349#M125335</link>
      <description>&lt;P&gt;So the complete working code is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME SASCBTBL CATALOG "work.temp.attrfile.source";
 
DATA _NULL_;
FILE SASCBTBL;
    PUT "ROUTINE WNetGetConnectionA MODULE=MPR MINARG=3 MAXARG=3 STACKPOP=CALLED RETURNS=LONG;";
    PUT "  ARG 1 CHAR INPUT BYADDR FORMAT=$CSTR200.;";
    PUT "  ARG 2 CHAR UPDATE BYADDR FORMAT=$CSTR200.;";
    PUT "  ARG 3 NUM UPDATE BYADDR FORMAT=PIB4.;";
RUN;


%MACRO getUNC ;
DATA _NULL_;
length input_dir $200 output_dir $200;
* The input directory can only be a drive letter + colon ONLY e.g. j: ;
input_dir = 'h:';
output_dir = ' ';
output_len = 200;
call module("WNetGetConnectionA", input_dir, output_dir, output_len);
call symputx('dir',input_dir,'l');
call symputx('path',output_dir,'l');
RUN;
%put drive letter is &amp;amp;dir;
%put path is &amp;amp;path;
%MEND getunc;

%getunc;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Aug 2018 11:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-UNC-path-for-a-mapped-drive/m-p/483349#M125335</guid>
      <dc:creator>alr</dc:creator>
      <dc:date>2018-08-02T11:20:24Z</dc:date>
    </item>
  </channel>
</rss>

