DATA Step, Macro, Functions and more

Regarding Datafiles restore

Reply
Occasional Contributor
Posts: 9

Regarding Datafiles restore

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.

Super User
Posts: 7,809

Re: Regarding Datafiles restore

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,970

Re: Regarding Datafiles restore

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.

Super User
Posts: 19,822

Re: Regarding Datafiles restore

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. 

Occasional Contributor
Posts: 9

Re: Regarding Datafiles restore

Hi Reeza,

 

Thanks for your kind reply. Please provide codings for the same.

 

Thanks..

Super User
Posts: 7,809

Re: Regarding Datafiles restore


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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 9

Re: Regarding Datafiles restore

Posted in reply to KurtBremser

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...

Super User
Posts: 7,809

Re: Regarding Datafiles restore

https://support.microsoft.com/en-us/help/17127/windows-back-up-restore

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 9

Re: Regarding Datafiles restore

Posted in reply to KurtBremser

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

Super User
Posts: 7,809

Re: Regarding Datafiles restore

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).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 9

Re: Regarding Datafiles restore

Posted in reply to KurtBremser

Hi,

 

Thank you so much..

 

 

Occasional Contributor
Posts: 9

Opening an excel using SAS

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.

 

 

Occasional Contributor
Posts: 9

Re: Opening an excel using SAS

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;

Super User
Posts: 7,809

Re: Opening an excel using SAS

[ Edited ]

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?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,970

Re: Opening an excel using SAS

What is it your trying to do?  Why do you need to open Excel?

Ask a Question
Discussion stats
  • 18 replies
  • 132 views
  • 1 like
  • 4 in conversation