BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
newbi
SAS Employee

I have program that imports the source data into sas dataset daily.  Is it possible in SAS to create empty data file and export it to some location when the actual source file is not found ?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

You could always use one of the methods combined with a macro as shown at:

http://support.sas.com/kb/24/670.html

View solution in original post

6 REPLIES 6
art297
Opal | Level 21

Of course!  You can use either a datastep or proc sql and just assign a libname to the directory where you want it to exist.  e.g.,

DATA CORP.want;

   SET CORP.have;

   STOP;

RUN;

PROC SQL noprint;

  CREATE TABLE CORP.want

    LIKE CORP.have

  ;

quit;

data_null__
Jade | Level 19

Do you want a data set with variables and zero obs or zero variables and zero obs?  If you want variables and zero obs do you have a data set where the variable attributes can be copied from?  For 0:0 you can use.

2128 data zero;

2129 stop;

2130 run;

NOTE: The data set WORK.ZERO has 0 observations and 0 variables.



The 0:0 data could be used in a program to add obs to an existing data set.  Where nothing happens unless the 0:0 is not 0:0 but actually has variables and observations.

2136 data class;

2137 set sashelp.class;

2138 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: The data set WORK.CLASS has 19 observations and 5 variables.

NOTE: DATA statement used (Total process time):

real time 0.01 seconds

cpu time 0.00 seconds

2139 data class;

2140 if 0 then modify class;

2141 set zero;

2142 output;

2143 run;

NOTE: The data set WORK.CLASS has been updated. There were 0 observations rewritten, 0

observations added and 0 observations deleted.

NOTE: There were 0 observations read from the data set WORK.ZERO.

So as you see it depends on what you have and what you want. :smileygrin:

newbi
SAS Employee

Thanks for all the reply.  I will try out both the option.

newbi
SAS Employee

I need to create empty table with variables.  Also, is it possible to check to see if the file exist if it does then use the original file as main source if it does not create empty data set to avoid the error.

Thanks in advance.

art297
Opal | Level 21

You could always use one of the methods combined with a macro as shown at:

http://support.sas.com/kb/24/670.html

newbi
SAS Employee

Thanks.  I use fileexist to check if the file exist or not.

Thanks for all your help

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 15903 views
  • 0 likes
  • 3 in conversation