SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Eliminate attaching a file which has no data

Reply
Contributor
Posts: 21

Eliminate attaching a file which has no data

Hi All,

 

I require your suggestion/ideas in sending mail communication

 

I have created a data job which will give result in excel file. Each file contains information on name, city and country. The files will be created even when the data is blank. And this file is sent as attachment using Email and FTP node. Like this I have 3 files which will be sent to the single sender. Sometimes the xls files will not have any data, so there will be blank sheet which will be sent as attachment. I want to eliminate this step and want to give a condition stating if there is no data in excel file then do not attach the file.

 

I have enclosed screen shot for your reference. if you view in the screen shot of file name :data3, the sheet is blank without any data. I do not need this file while sending the mail. Currently I am checking each file and if there is no data then removing the file from attachment in Email and FTP node by deleting the file path and sending it. This is on-going process and it will be difficult to keep looking at the data all the time and removing the file path. Any other ways you can recommend to avoid this step?

 

Please check and suggest.

  

Regards,

Shaheen

Super User
Posts: 7,830

Re: Eliminate attaching a file which has no data

[ Edited ]

a) do not post example code, data or results in Office files. Many organizations prevent or forbid downloading them.

   Post screenshots as .png, or copy text and use the {i} icon to use a fixed-width font for display

 

b)

To check if a file created from a dataset is empty, do this after creating the dataset:

data _null_;
call symput('num_recs',put(numrecs,best.));
set your_dataset nobs=numrecs;
stop;
run;

Now you can use &numrecs to have the count of observations in your dataset from which you export.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 21

Re: Eliminate attaching a file which has no data

Posted in reply to KurtBremser

Thnak you kurt for both the suggestions. I am beginner in SAS, so not sure in which node i have to use the below coding. I have tried using expression node but it is throwing error stating invalid expression. Please elaobrate it. From the below coding it looks like the condition reads whether data exist in file or not. do you also have a condition to avoid attaching these files?

Super User
Posts: 7,830

Re: Eliminate attaching a file which has no data

Please post the code (use the "little running man"/"Insert SAS Code" icon) to show how you attach the files. I/we can then look for ways to make such attaching conditional.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 21

Re: Eliminate attaching a file which has no data

I have already provided that in the screen shot which is attached earlier. I don’t write codes, just drag and drop the node into datajob. there are different nodes for input, output and utilities. Under utilities I have used ‘email and ftp’ node. Just dragged and provided email id’s, subject line and body of the test. Below the message, there is an option of attaching the files and the files are attached by browsing the path.

 

The files are stored in dataset and also in csv file. I am attaching csv files.

Super User
Posts: 7,830

Re: Eliminate attaching a file which has no data

Ouch. So you are restricted to use only the parts supplied by the Dataflux interface. Then somebody else needs to jump in, as I've never used such frontends.

I guess(!) you might be able to set a condition for each individual call of the node, but not for the action within the node itself.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 430 views
  • 0 likes
  • 2 in conversation