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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 3 replies
  • 1441 views
  • 0 likes
  • 3 in conversation