BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JNWong
Calcite | Level 5

hi,

 

  i am wondering how to transfer the dataset to memory, now i have a dataset in sas library, i am expected to transfer it to memory,  it is my professer's suggestion, and i never try to do it before. 

 

i knew that the stata operated in the memory. i have no idea about sas.

 

the 'memory'  just is the thing displayed in the windows task manager.

 

thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

There's no point in transferring a data set to memory unless you plan to access it multiple times within your sas program.  After all it has to be read from disk at least once.

 

But there is a way to load into memory.  Take a look at documentation of the sasfile statement sasfile statement.  It includes an example of "using sasfile in a program with multiple steps".

 

However, be aware of limitations.  There are limited ways to modify the contens of a dataset loaded into memory via the sasfile statement.  The table below has a list of limitations:

 

Processing Requests for a File Opened by SASFILE
Processing Request
Open Mode
Allowed
APPEND procedure
update
Yes
DATA step that creates or replaces the file
output
No
DATASETS procedure to rename or add a variable, add or change a label, or add or remove integrity constraints or indexes
utility
No
DATASETS procedure with AGE, CHANGE, or DELETE statements
does not open the file but requires exclusive access
No
FSEDIT procedure
update
Yes
PRINT procedure
input
Yes
SORT procedure that replaces original data set with sorted one
output
No
SQL procedure to modify, add, or delete observations
update
Yes
SQL procedure with CREATE TABLE or CREATE VIEW statement
output
No
SQL procedure to create or remove integrity constraints or indexes
utility
No
 

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

5 REPLIES 5
mkeintz
PROC Star

There's no point in transferring a data set to memory unless you plan to access it multiple times within your sas program.  After all it has to be read from disk at least once.

 

But there is a way to load into memory.  Take a look at documentation of the sasfile statement sasfile statement.  It includes an example of "using sasfile in a program with multiple steps".

 

However, be aware of limitations.  There are limited ways to modify the contens of a dataset loaded into memory via the sasfile statement.  The table below has a list of limitations:

 

Processing Requests for a File Opened by SASFILE
Processing Request
Open Mode
Allowed
APPEND procedure
update
Yes
DATA step that creates or replaces the file
output
No
DATASETS procedure to rename or add a variable, add or change a label, or add or remove integrity constraints or indexes
utility
No
DATASETS procedure with AGE, CHANGE, or DELETE statements
does not open the file but requires exclusive access
No
FSEDIT procedure
update
Yes
PRINT procedure
input
Yes
SORT procedure that replaces original data set with sorted one
output
No
SQL procedure to modify, add, or delete observations
update
Yes
SQL procedure with CREATE TABLE or CREATE VIEW statement
output
No
SQL procedure to create or remove integrity constraints or indexes
utility
No
 

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Reeza
Super User

I'm guessing you likely mean you want to permanently save the dataset so you don't have to reimport it rather than actually save it to 'memory' which would usually be understood to be RAM. 

 

You can do this by first assigning a permanent library and then copying the file to that location.

 

libname MEM '/folders/myfolders/perm';

data mem.class;
set sashelp.class;
run;

Remember, that to access the data in the future you'll need to re-assign the library if you haven't set it to be assigned automatically at start up. 

JNWong
Calcite | Level 5

thanks! as i knew little about the 'memory',actually, it is the RAM which you have mentioned above.

and i try the code like:

 

%let dsets = a ;
libname TEMP 'C:\Windows\TEMP' ACCESS=TEMP;
data temp.TEST_ML;
set &dsets;
run;

 

sorry for another question,is the TEMP  'cache' for sas?  someone has told me that delete the 'temp' folder when you finished your work. i did not know the reson. 

 

thank you!

Reeza
Super User

Temp in this case is a library and the data is not deleted. Typically SAS datasets without a two level name (ie no libname) are stored in the WORK library. Anything in the work library is erased when you end your SAS session. 

 

If you are trying to work in RAM, my first answer/code is incorrect. 

 

If you're trying to work in memory, maybe you should explain what you want to do in memory. Is it a lookup, merge, sort? 

I'm assuming this is an attempt to improve performance? 

 

JNWong
Calcite | Level 5

yeah, i want to improve the performance. and use the ram, sorry i called it 'memory'.

 

i think the path TEMP 'C:\Windows\TEMP'  (which used to set up the 'temp' to use the RAM)

 

as 'C:\Windows\TEMP' this folder  already  exists there, maybe made automatically by sas. i am wondering if  this folder can be used to transfer the dataset to ram. or i should set up a new folder named 'temp' in 'c'   and change the path like'c:\temp'.

 

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!

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