Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAS Q - Table creation IF it doesn't already exist? 1

Status
Not open for further replies.

seedubbs

Programmer
Sep 1, 2005
2
US
I would like to be able to do something like the following:

if data ONE exists then do {x,y,z};

else create data ONE; do {x,y,z};

basically i want a way to see if a permanent dataset already exists...

any ideas?

Thanks. (i'm new to this forum, and all programming forums, so bear with me!)

Seedubbs
 
I think that there was a similar post a couple of months ago on this forum... someone posted macro which detects if a dataset exists or not.

Also, I'd change the logic slightly.

IF dataset does not exist then create dataset;
do xyz;

slightly less coding and it makes it clearer that whatever happens you are doing xyz.

I'll see if I can find the macro and I'll post a link here.
 
Seedubbs,

Your task is best suited for a macro, yet you may want to do the task w/o using the macro facility. Perhaps you are testing a Dataset that doesn't exist when the macro will execute.

Both can be done by using the EXIST() function. In macro you would wrap the function in a %SYSFUNC() call, and in reg code you would use it in a data step with an explicit output statement. You can also check that a dataset exists by checking the sashelp.vmember view.

**ex. of explicit output statment;
data one two three;
set you_Oldds;
if exist(one) = 0 then
output one;
etc...
run;

Hope that this helped you out.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top