BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ManoharNath
Obsidian | Level 7

Hi Everyone, I need one help related to SAS automated email which send email to every other individuals.

 

Task is : There is 6 unique segments of videos link and its description which need to be send to customers.

suppose AAA customer is receiving 1  videos link and 1 video description and others can receive 2 or more videos link with its description for every customers.

 

Others customers can not see others email, it has to be send to every individual or row wise.

 

I appreciate the help and I am able to solve the problem and now I am getting only one problem.
I can see video link and its description but for some customers whom we don't have videos, for that its resolving to "" and coming in email. I am looking to avoid this "" in email. can you please suggest how to overcome this problem

 

for 1st customer it have 1st segment video link and description and I am getting that information, but for rest segment it don't have video segment as expected and it has to be missing but getting "" "" "" this.

 

Output I am getting:

Take a look at the short video.

Collections Strategies

" " " " " " " " " "

Now trying to avoid or compress this (" " " " " " " " " ) from the email.

 

 

For example;

Link Desc: Collection Stratigies

Link: https://www.youtube.com/watch?v=6TK20Y5oD9s

 

need help to write sas code which can send email to this customers dynamically.

 

first_name

EMAIL_ADDRESS

Video_segment1

Video_segment2

Video_segment3

Video_segment4

Video_segment5

Video_segment6

AAA

AAA@COM

Yes

       

 

BBB

BBB@COM

Yes

yes

     

 

CCC

CCC@COM

Yes

yes

yes

   

 

DDD

DDD@COM

Yes

       

 

EEE

EEE@COM

     

Yes

yes

 

FFF

FFF@COM

Yes

Yes

Yes

Yes

Yes

Yes

GGG

GGG@COM

Yes

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ManoharNath
Obsidian | Level 7

Sorry for delay in response and thank you everyone for your revert.

I was able to solve the prolem by using %if and %len method. 

 

This resolved the problem.

%if %length(Video_segment1) > 0 %then %do;

%put &Video_segment1.;

%put &Video_Desc.;

end;

View solution in original post

4 REPLIES 4
SASJedi
SAS Super FREQ

Hey, @ManoharNath - First, review this excellent library article about sending email from SAS by @ChrisHemedingerTip: How to send email using SAS with particular emphasis on the section titled "Sending a customized message to multiple addresses". I've stolen the code from the macro used there as a starter for your solution. The rest is just simple conditional programming. Here is a pseudo-code template to get you started:

 data _null_;
	set customer_list;
	array vids[6] video:;
	array vidlink[6] $400 _temporary_ 
		('Collection Stratigies: https://www.youtube.com/watch?v=6TK20Y5oD9s,
		 ... LIST THE REST OF THE LINKS AND DESCRIPTIONS HERE ...);
	FILE outbox
		to=(EMAIL_ADDRESS ) 
		subject="Your video links";
	Salutation =cats(catx(" ","Dear",first_name),',');
	put Salutation;
	put;
	put "Here are your video links:"; 
	do I=1 to dim(vids);
		if lowcase(vids[i])='yes' then
		put vidlink[i];
	end;
	put;
	put "All the best,";
	put "Me";
  run;

Hope this helps.

Mark

 

 

Check out my Jedi SAS Tricks for SAS Users
ManoharNath
Obsidian | Level 7

I appreciate the help and I am able to solve the problem and now I am getting only one problem.
I can see video link and its description but for some customers whom we don't have videos, for that its resolving to "" and coming in email. I am looking to avoid this "" in email. can you please suggest how to overcome this problem

 

for 1st customer it have 1st segment video link and description and I am getting that information, but for rest segment it don't have video segment as expected and it has to be missing but getting "" "" "" this.

 

Output I am getting:

Take a look at the short video.

Collections Strategies

" " " " " " " " " "

Now trying to avoid or compress this (" " " " " " " " " ) from the email.

 

SASJedi
SAS Super FREQ

Once again, I'd suggest conditional coding for that line of the email. For example:

	if find(lowcase(cats(of vids[*])), 'yes') then do;
		put "Here are your video links:"; 
		do I=1 to dim(vids);
			if lowcase(vids[i])='yes' then
			put vidlink[i];
		end;
	end;
	else put "You have no videos to view";

Mark

 

Check out my Jedi SAS Tricks for SAS Users
ManoharNath
Obsidian | Level 7

Sorry for delay in response and thank you everyone for your revert.

I was able to solve the prolem by using %if and %len method. 

 

This resolved the problem.

%if %length(Video_segment1) > 0 %then %do;

%put &Video_segment1.;

%put &Video_Desc.;

end;

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
  • 4 replies
  • 911 views
  • 5 likes
  • 2 in conversation