BookmarkSubscribeRSS Feed
Shah
Obsidian | Level 7

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

5 REPLIES 5
Kurt_Bremser
Super User

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.

Shah
Obsidian | Level 7

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?

Kurt_Bremser
Super User

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.

Shah
Obsidian | Level 7

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.

Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1428 views
  • 0 likes
  • 2 in conversation