BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6

Hello everyone,

I try to open a password protected excel file as the following SAS code,,,everything works but only problem will happen when I try to use macro variable denotes the password.

Suppose the password of the excel file c:\temp\book1.xls  is abcdefg.

Please look into SAS code ,I add my question there at ""s = '[open(' || quote ("c:\temp\book1.xls.") ||',,,,"abcdefg")]';""   (I want use macro variable express abcdefg will cause problem).

Thanks

Mike

options noxwait noxsync;

    x '"C:\Program Files\Microsoft Office\Office12\EXCEL"';

    data _null_;
        x=sleep(3);
    run;

    filename ExcelCmd dde 'Excel|system';

    data _null_;
      file ExcelCmd;
      length s $200;
      s = '[open(' || quote ("c:\temp\book1.xls.") ||',,,,"abcdefg")]'; /*-------------My question is here,the password is "abcdefg",but I want use a macro variable replace the real password,such as  I want use %let pw=abcdefg,and here I use &pw instead of abcdefg,but a problem will happen-----------------------*/
      put s;
    run;

3 REPLIES 3
FloydNevseta
Pyrite | Level 9

I'm not familiar with DDE, but have much experience converting code to use macro variables. Try enclosing the DDE command in double quotes instead of single quotes. The single quotes are probably preventing the resolution of the macro &pw, so the proper password does not get passed to Excel.

art297
Opal | Level 21

try it with:

      s = '[open(' || quote ("c:\temp\book1.xls.") ||",,,,""&pw."")]";

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 757 views
  • 0 likes
  • 3 in conversation