BookmarkSubscribeRSS Feed
james_alive
Calcite | Level 5

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

3 REPLIES 3
LinusH
Tourmaline | Level 20
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
james_alive
Calcite | Level 5
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.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1685 views
  • 0 likes
  • 3 in conversation