03-21-2012 08:20 AM
I am a new user in SAS. I have shifted from R. I am dealing with a large data (hospitalization).
Everyday I open SAS, I loose a lot of time to run all the previous codes to get the formatted and structured data for further use.
In R I used to save workspace and thus everyday when I start I could get back the latest works of previous day.
Is it possible here with SAS to save workspace given that I have SAS Base and Enterpirse Guide?
03-21-2012 09:19 AM
If you save your files in a permanent directory (e.g., use a libname statement to define a library like:
libname mydata "c:\current_data";
then, in your code, rather than just creating the files in your work directory (i.e., using something like:
Create them as permanent files. e.g.:
Then, the next day, you just have to run the one line: libname mydata "c:\current_data";
and all of your files will be accessible
03-21-2012 09:56 AM
SAS supports a neat trick that lets you save the WORK area with minimal changes to your SAS program. These changes have to be implemented at the beginning of your program, before adding to the WORK area.
As Art mentioned, you have to pre-define a folder where the WORK area will reside, using a LIBNAME statement. From that point, however, you don't need to change the subsequent DATA and PROC steps. Instead, add this line to the program (assuming the LIBNAME statement defined "mydata"):
The default option is user=WORK. That's why your one-level data set names get stored in the WORK library.
Here's the part I'm not sure about. If you want to re-use the same WORK area in a subsequent program, is it as simple as adding the same two lines to the subsequent program? I suspect it is, but I'm not positive about that.
Of course, Art's method will give you better control if you wish to save just part of the WORK area and discard the rest.
03-22-2012 01:59 AM
Thanks a lot Art297 & Astounding.
I have applied method of Art297. While reopening, it was not throwing the data and may be that was because of more complication of the program.e.g.
/* formatting, restructuring, reformating, count */
So can anybody help me to understand why I cannot retrieve my saved data in permanent library, even though I gave the path for the libref next day ?
What you were suspicious I tried. It works even when model output is needed to retrieve but in my purpose regarding several times formatting, restructuring, SQL joins etc, it is not working. So till now what way I have is to export all to csv at the end of the day and import on the next day. U know it causes loss of information that are capable with SAS data.