BookmarkSubscribeRSS Feed
rajenr
Calcite | Level 5

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.

18 REPLIES 18
Kurt_Bremser
Super User

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Reeza
Super User

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. 

rajenr
Calcite | Level 5

Hi Reeza,

 

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

 

Thanks..

Kurt_Bremser
Super User

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

rajenr
Calcite | Level 5

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

rajenr
Calcite | Level 5

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

Kurt_Bremser
Super User

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

rajenr
Calcite | Level 5

Hi,

 

Thank you so much..

 

 

rajenr
Calcite | Level 5

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.

 

 

rajenr
Calcite | Level 5

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;

Kurt_Bremser
Super User

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?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

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
  • 18 replies
  • 1248 views
  • 1 like
  • 4 in conversation