Hi Friends,
I Would like to know that the sas SAS7BDAT File (.sas7bdat) can be restored to the previous version or the date by using sas programmings.
If yes please proivde sas codings for the same.
Unless you added generations to the dataset, you have no way to recreate an earlier version of a SAS dataset by SAS means, short of re-running the code that produced the dataset in the first place. When SAS rewrites a dataset, the previous version of the dataset is deleted.
So your best bet is a multi-generation backup from which you can restore the wanted version.
I would suggest if your at the stage where your trying to restore something from old version in anything other than toal fail, then your to late in the process. Look at it earlier on, have a central data area, where users copy data out to working areas. I.e. prevent the need to rollback before it happens. Ok, it wont cover all eventualities, but should minimize them.
If you have a system type backup, ie Windows backup you may be able to restore previous version by using PowerShell commands that you can execute within SAS.
Hi Reeza,
Thanks for your kind reply. Please provide codings for the same.
Thanks..
@rajenr wrote:
Hi Reeza,
Thanks for your kind reply. Please provide codings for the same.
Thanks..
How you do the restore depends on the backup you have set up, so that is completely up to you. Remember that this will be a Windows task, while this forum here deals with SAS.
Hi,
I would like to restore the dataset based on the windows backup(like previous day). Request you to provide codings for the same.
Thanks...
Hi KurtBremser,
Thanks for your advise. I would like to restore the datasets using SAS programmings. As suggested by Reeza it can be possible by using PowerShell commands in SAS. Kindly help on this..
Thanks
Powershell is Windows programming. You need to solve that part first, before you have something that you can call from SAS with call system, X or filename pipe.
So I recommend to solve the restore from a commandline, and once that works, write the corresponding system call in SAS.
There is no generic SAS interface to operating system backup/restore commands (like the SAS file functions that allow you to deal with files without knowing the OS commands).
Hi,
Thank you so much..
Hi Friends,
I tried with the below code for open an excel. But it does it provides any output. I could see the log window without error. Please check and help on this. Here with i have attached screenshot of log Window.
%MACRO Sleep(pSeconds);
DATA _NULL_;
vVar1=SLEEP(&pSeconds);
RUN;
%MEND;
/* Macro to open Excel */
%MACRO Open_Xls();
OPTIONS NOXWAIT NOXSYNC MISSING='';
X "C:\Program Files\Microsoft Office\Office14\excel.exe";
%sleep(2);
%MEND;
Note: Excel path is correct.
Hi team,
I have checked with the below path also. But it does not open an excel file.
%MACRO Open_Xls();
OPTIONS NOXWAIT NOXSYNC MISSING='';
X "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE";
%sleep(2);
%MEND;
%MACRO Sleep(pSeconds);
DATA _NULL_;
vVar1=SLEEP(&pSeconds);
RUN;
%MEND;
/* Macro to open Excel */
%MACRO Open_Xls();
OPTIONS NOXWAIT NOXSYNC MISSING='';
X "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE";
%sleep(2);
%MEND;
The problem with the X statement in SAS is that it does not deliver anything back from the commandline.
You can try this to capture OS responses:
filename oscmd pipe "your command 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
the 2>&1 reroutes error output to standard output; all responses will now end up in your SAS log.
As it is, your code would just open an instance of Excel on the PC without doing anything further; is this what you intend to do?
What is it your trying to do? Why do you need to open Excel?
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.