BookmarkSubscribeRSS Feed
Dipanjan
Calcite | Level 5

Hi,

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?

Dipanjan

4 REPLIES 4
art297
Opal | Level 21

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:

data step1;

*whatever;

run;

Create them as permanent files.  e.g.:

data mydata.step1;

*whatever;

run;

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

Astounding
PROC Star

Dinpanjan,

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"):

options user=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.

Good luck.

Dipanjan
Calcite | Level 5

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.

data work.a;

set permanent.b;

/*subsetting*/

run;

data permanent.final;

set work.a;

/* formatting, restructuring, reformating, count */

run;

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 ?

Astounding,

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.

Tobin_Scroggins
Calcite | Level 5

This post from Angela Hall might help.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 2257 views
  • 6 likes
  • 4 in conversation