DATA Step, Macro, Functions and more

Disable overwrite of SAS dataset, keep it intact over macro process

Reply
New Contributor
Posts: 3

Disable overwrite of SAS dataset, keep it intact over macro process

Hello All, it would be nice if someone can help me out on this.

I have a process set up in SAS EG, it needs macro to iteratively run over few specific steps. One of the data steps has a temporary dataset that keeps getting overwritten. I need to disable this so i can export the whole list to an excel

any suggestions ?

 

PROC Star
Posts: 1,400

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Posted in reply to spynish29

I am not sure I understand your question exactly.. You have some data set that you do not want to be overwritten, is that it?

 

Perhaps use the REPLACE= Data Set Option

New Contributor
Posts: 3

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Hello there ..thanks for the reply..

to your question - yes.. there is a temporary dataset thats part of a series of steps that get called iteratively by macro.

I have the options (repempty=no replace=yes); setup .. however it still does not retain the data it had from the first run. It just has the data from final macro run.

 

Super User
Posts: 10,524

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Posted in reply to spynish29

A date step or a create table in sql will always overwrite the existing. Why don't you use proc append?

And what does your macro do? I ask because in 90% of macro questions here on the communities, the solution is to not use a macro.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 3

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Posted in reply to KurtBremser

Hi Kurt,

 

the macro basically calls and reruns the logistic regression post removing some insignificant variables (so the dataset in question is capturing all removed variables) the logistic reruns after removal of variables and then it overwrites the earlier removed variables in the dataset with the ones that have been removed at last.

hope im making sense here ..

Super User
Posts: 10,524

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Posted in reply to spynish29

Then you should initialize an empty dataset before the iteration starts and append the temporary data in each iteration.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,790

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Posted in reply to KurtBremser

Or quesiton why your doing an interative process in the first place.  Likely due to use of macro code, splitting data up or something like that.  Put all your data together then use by groups, its far simpler, easier to code, and you don't end up with a macro mess.  Hard to say without test data and what code you have written.

Super User
Posts: 13,868

Re: Disable overwrite of SAS dataset, keep it intact over macro process

Posted in reply to spynish29

@spynish29 wrote:

Hi Kurt,

 

the macro basically calls and reruns the logistic regression post removing some insignificant variables (so the dataset in question is capturing all removed variables) the logistic reruns after removal of variables and then it overwrites the earlier removed variables in the dataset with the ones that have been removed at last.

hope im making sense here ..


Perhaps you might want to examine the options in Proc Logistic (or most of the regression procs) about variable SELECTION option and related options such as DETAILS on the model statement that provides output about the steps of the selection process and effects.

 

Spend some time working with just the proc logistic code before delving into macro code to duplicate what the programmers at SAS have likely already implemented.

This may require actually writing code as I am not sure that every single option combination is available in a point and click task.

Ask a Question
Discussion stats
  • 7 replies
  • 136 views
  • 0 likes
  • 5 in conversation