BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alr
Quartz | Level 8 alr
Quartz | Level 8

Hi,

I need to get UNC path for a mapped drive as different users have their HOME drive on different servers.

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 (http://www2.sas.com/proceedings/forum2008/023-2008.pdf).

 

 

%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 &dir;
%put path is &path;
%MEND getunc;

%getunc;

 

But get following error:

NOTE: Invalid argument to function MODULE('WNetGetConne'[12 of 18 characters shown],'h:

        '[12 of 200 characters shown],'            '[12 of 200 characters shown],200) at line

      1 column 186.

input_dir=h: output_dir=  output_len=200 _ERROR_=1 _N_=1

 

I am on Window 10 and use SAS 9.4

 

Can anyone see what is going wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

I tried to copy/paste the code in the document and the problem occurred as you described.

It appeared that the copy/paste has concatenated two arguments of the routine instruction :

 

STACKPOP=CALLEDRETURNS=LONG

 

instead of

 

STACKPOP=CALLED RETURNS=LONG

 

Adding a space solved the problem.

View solution in original post

3 REPLIES 3
gamotte
Rhodochrosite | Level 12

Hello,

 

I tried to copy/paste the code in the document and the problem occurred as you described.

It appeared that the copy/paste has concatenated two arguments of the routine instruction :

 

STACKPOP=CALLEDRETURNS=LONG

 

instead of

 

STACKPOP=CALLED RETURNS=LONG

 

Adding a space solved the problem.

alr
Quartz | Level 8 alr
Quartz | Level 8

Thank you

alr
Quartz | Level 8 alr
Quartz | Level 8

So the complete working code is:

 

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 &dir;
%put path is &path;
%MEND getunc;

%getunc;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2629 views
  • 1 like
  • 2 in conversation