0
votes

I have SAS code that reads my password from an external .txtfile and establishes connection with odbc . When i run the following code in SAS, it works fine

filename pw "C:/xxxx"; 

data _NULL_ ;
  infile pw  ; 
  input pw : $50. ;
  call symputx('pwd',pwd);
run;

libname xxx odbc user=myUser password=&pwd. dsn=myDsn schema=mySchema;

proc sql;  
  connect to xxx(dsn=myDsn user=myUser password=&pwd.);

However when I create a batch file to run it from Windows task scheduler or run it from SAS Enterprise Guide I get Apparent symbolic reference PWD not resolved

Why is this happening ? How to deal with this issue ?

2
If you're running from Enterprise Guide the code you're submitting could be running on a remote server, in which case it might not be able to 'see' your C: drive. Do you get any errors from the data-step?mjsqu

2 Answers

5
votes

Because your call symputx is not correctly defining it, at least based on the code you pasted.

data _NULL_ ;
  infile pw  ; 
  input pw : $50. ;
  call symputx('pwd',pw);
run;

That would be the correct syntax (or change the input statement to read pwd). Look at your datastep's log, it should have a warning pwd was uninitialized.

If you pasted the code properly, I would still look to your data step's log, and see if any rows were processed. mjsqu may be correct in that you may not have visibility to the directory (if this is on a server and you're not accessing a server-visible directory), or some other issue may present as a result of you being in a different environment.

4
votes

You have a typo. My guess is that your original variable was named pwd and you tested your code and it ran fine and then you renamed it. If you close your sas session and try rerunning it I bet it fails.

Try changing to this:

filename pw "C:/xxxx"; 

data _NULL_ ;
  infile pw  ; 
  input pw : $50. ;
  call symputx('pwd',pw);
run;