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

I thought I understood how the memtype option in proc datasets worked, but I guess I was wrong. My program creates lots of temporary datasets as well as some formats and macros. I need to delete most--but not all--of the datasets after each iteration of a particular macro, but I need to save some sets and all formats and macros. I thought memtype=data would exclude macros and formats from deletion, but the formats are still getting deleted. What am I doing wrong?

 

proc datasets lib=work nolist;
	save c final: template: / memtype=data; *these are all data sets;
quit;

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
AMSAS
SAS Super FREQ

@Mike_B Here's a simple example that explains what is happening 

See bullet #2 In Subordinate Statements:

after a slash (/) at the end of the statement. When used following a slash, the MEMTYPE= option refers to all SAS files named in the statement unless the option appears in parentheses after the name of a SAS file. For example, the following statement deletes Lotpix.catalog, Regions.data, and Appl.catalog:

delete lotpix regions(memtype=data) appl / memtype=catalog;

 

i.e. MEMTYPE applies to the datasets you have listed in the SAVE statement 

 

In the example below, I create a formats catalog and a formats dataset, when the PROC DATASETS executes it will delete the formats catalog as the MEMTYP=DATA tells it only to save the FORMATS dataset

Hope this helps

 

 

proc format ;
	value
		$sex "M"="Male" "F"="Female" ;
run ;

data work.test1 ;
	do i=1 to 5 ;
		output ;
	end ;
run ;

data work.test2 ;
	do i=1 to 5 ;
		output ;
	end ;
run ;

data work.formats ;
	do i=1 to 5 ;
		output ;
	end ;
run ;

proc datasets lib=work nolist ;	
	save test2  formats / memtype=data; /* memtype only applies to the list of datasets in the SAVe statement */
	                                    /* i.e. the formats dataset is not deleted but the formats catalog is */
quit;

 

 

View solution in original post

2 REPLIES 2
AMSAS
SAS Super FREQ

@Mike_B Here's a simple example that explains what is happening 

See bullet #2 In Subordinate Statements:

after a slash (/) at the end of the statement. When used following a slash, the MEMTYPE= option refers to all SAS files named in the statement unless the option appears in parentheses after the name of a SAS file. For example, the following statement deletes Lotpix.catalog, Regions.data, and Appl.catalog:

delete lotpix regions(memtype=data) appl / memtype=catalog;

 

i.e. MEMTYPE applies to the datasets you have listed in the SAVE statement 

 

In the example below, I create a formats catalog and a formats dataset, when the PROC DATASETS executes it will delete the formats catalog as the MEMTYP=DATA tells it only to save the FORMATS dataset

Hope this helps

 

 

proc format ;
	value
		$sex "M"="Male" "F"="Female" ;
run ;

data work.test1 ;
	do i=1 to 5 ;
		output ;
	end ;
run ;

data work.test2 ;
	do i=1 to 5 ;
		output ;
	end ;
run ;

data work.formats ;
	do i=1 to 5 ;
		output ;
	end ;
run ;

proc datasets lib=work nolist ;	
	save test2  formats / memtype=data; /* memtype only applies to the list of datasets in the SAVe statement */
	                                    /* i.e. the formats dataset is not deleted but the formats catalog is */
quit;

 

 

Mike_B
Obsidian | Level 7

Thank you. I modified (below), and it now saves the format catalog as well as the data files.

proc datasets lib=work nolist memtype=(data catalog);
  save c final: template: formats;
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1510 views
  • 3 likes
  • 2 in conversation