Help using Base SAS procedures

SAS Datasets Backup & Restore (SAS 9.2)

Reply
Occasional Contributor
Posts: 8

SAS Datasets Backup & Restore (SAS 9.2)

Hi, 

 

I have build a SAS program which, on quarterly basis will execute and program will import all the new quarter data files from PC Folder into SAS, and then will perform the calculations and produce required output dataset (and then export the details to PC folder).

 

But prior to this process, I'd like to check whether the output dataset is already present, if yes then take a backup of the same and store it in a different location (with new name as DataSetName_DateTimeStamp). Furthermore, if need be I'll have to check this backup file for re-run activity.

 

Can anybody advise what process or steps should I follow to get this done.

 

Thanks, SAS NewBee..

Super User
Posts: 5,254

Re: SAS Datasets Backup & Restore (SAS 9.2)

If you are not going to use those backup data sets I think this is a job for a backup system.
In SAS, I see a macro, or code generated by call execute. You can use sashelp.vstable to drive your code.
Data never sleeps
Occasional Contributor
Posts: 8

Re: SAS Datasets Backup & Restore (SAS 9.2)

Thanks for your prompt reply LinusH, However I may or may not have to use the backup datasets. Worst Case scenario, if there comes a data extraction request for the previous quarters, then I'll have to check the backup data.

Hence, I need a way to create a smooth backup & restore functionality/program.
Super User
Super User
Posts: 7,392

Re: SAS Datasets Backup & Restore (SAS 9.2)

Hi,

 

@LinusH is quite correct, there are plenty of software solutions already available for free and paid which are designed to do such things.  For example, whilst TortoiseSVN is really for text files, you can set it up to keep version history on all your files, then you can have multiple branches for the various imports, and when done merge everything back to main development area.  

 

Whilst you write a long program which goes through checking (using %sysfunc(fileexist() for example), and then datasetp setting to new libnames and such like, it both becomes unwieldy - just manging all the different versions, and programming becomes more complicated.

 

If you don't want to/can't use version control software - and to be honest in this day and age it should be used by everyone regardless of role/type of work - then why not make a collected dataset with each quarter appended to the data already there.  Then you could have an additional variable quarter which identifies each block of data - so you only have one dataset, but can still subset out each quarter dataset based on this variable.  Far simpler to implement and maintan, but data may get big!  

 

A final methodology would be to emulate a cube structure by putting quarter in the dataset name, e.g. MY_QTR1, MY_QTR2.  By doing this you always have all data there, and it takes up the same space on the drive as a big dataset, but would be quicker to access, though programming becomes a bit more difficult, negated if you can know the quarter up front of course.

 

Finally to go back to my original point, recreating software that is already available and field tested is not a good idea.  Even if you followed SDLC process, documented everything, tested fully, the lifecycled the whole thing, you would still end up with a product which is a) harder for users to understand - as its not widely used, b) harder to maintain - as you have to do it, c) buggier.

Ask a Question
Discussion stats
  • 3 replies
  • 348 views
  • 0 likes
  • 3 in conversation