What are you trying to do? Opening an Excel with the code you've shown will do exactly that, open Excel which is pretty useless.
Also, you have macro's shown but you're not actually calling them. Consider a macro similar (but not the same) as a function in another language. You've created the function but you haven't used it. You also may have an 'order of operations' issue. You define the SLEEP macro after it's used in the OPEN_XLS macro.
Do note that DDE requires the XCMD option to be enabled and usually doesn't work on server environments because they're Unix not Windows and those are Windows commands. Also, it's ancient. That doesn't mean it's not useful, just that it's ancient, finicky and I wouldn't build anything with this today.
%MACRO Sleep(pSeconds);
DATA _NULL_;
vVar1=SLEEP(&pSeconds);
RUN;
%MEND;
%MACRO Open_Xls();
OPTIONS NOXWAIT NOXSYNC MISSING='';
X "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE";
%sleep(2);
%MEND;
%open_xls;
Actually my concern is need to restore datasets using sas program. I tried for for t he same. As suggested by you and @Kurt_Bremser, i tried to restore the datasets using commands in command prompt. But i didn't get the commands for the same. While searching regarding this i could see some VB codings for restore the SQL database files.
So i planned to use those commands in Excel. But while running the SAS program the excel macro also need to run. If i can open the excel file then i will able to run the macro easily. So only i tried to open the file using the given commands. But i couldn't. Here i have some concerns, same are listed below.
1. Need to restore the datasets using SAS program.
2. If it is possible ways to do that and coding for the same.
Please help on this...
You seem to be going round in circles. Start by defining - where did the data come from originally? If you have the source files then re-import the data, if you don't have the source data, and you have removed the files, then you need ot go back to your IT and see if they have an automatic back up. It hard to say as we have no information on your process other than your trying to restore something. You need to provide all the infomation around the problem so we can know as well.
As already stated, you absolutely need to solve the "restore from commandline" issue first. If you can't do it from there, you can't do it, period. Involving another silly mechanism like Excel just to run a VB script borders on the insane.
How to run VB scripts from the commandline:
https://technet.microsoft.com/en-us/library/ee156587.aspx
(BTW, this is the first result of a google search for "run vb script from the commandline".
The same search also reveals lots of usable hints for the task)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.