BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Darshik
Calcite | Level 5

I have a frequently updated database of email id's of unsubscribed users and I need to move them from a Master database to the Unsubscribed email database on the 1st day of every month. 

 

I started SAS programming only about 2 weeks ago so I have a couple of question on how do I go about this. Please bear in mind that I am still studying to be a bit fluent with the array and macro functions and concepts. 

 

1. Can I create a Macro that frequently checks and moves the emails on the 1st day of every month, from insurance_master sheet to unsubscribed sheet??

2. Or should I create an Array.
3. Or use an Array within the Macro?

 

I have 2 datasets:

1 - darshik.insurance_master {variables email & type } type is char variable with the indutsry type info.

2 - darshik.unsubscribed {variables email & unsb } Unsb is numeric variable with values 0 & 1

 

I am unable to put up any code as an example as I am thoroughly confused at this point on where and how to begin. So far I have only removed the duplicates from both the files.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

If you only have to remove emails (from the insurance_master) that are also on the unsubscribe dataset with an unsb value of 1, then you could simply run the following at on the first of every month:

proc sort data=insurance_master;
  by email;
run;

proc sort data=unsubscribed;
  by email;
run;

data updated_insurance_master (drop=unsb);
  merge insurance_master unsubscribed;
  by email;
  if not unsb eq 1;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

Welcome to the forum and to the wonderful world of SAS Programming 🙂

 

With problems like this, it is often of great help to us if you post some sample of your data, or some data that resembles the data you have on hand. 

Darshik
Calcite | Level 5

Thank you for the welcome and your response.

 

I absolutely agree that posting some form of code is always helpful to provide more insight. However, I couldn't find a way to write something so I didn't have any existing code to provide.

 

However, I am doing some more research and trying and come up with a program, and I will post it here as soon as I can Smiley Happy 

art297
Opal | Level 21

If you only have to remove emails (from the insurance_master) that are also on the unsubscribe dataset with an unsb value of 1, then you could simply run the following at on the first of every month:

proc sort data=insurance_master;
  by email;
run;

proc sort data=unsubscribed;
  by email;
run;

data updated_insurance_master (drop=unsb);
  merge insurance_master unsubscribed;
  by email;
  if not unsb eq 1;
run;

Art, CEO, AnalystFinder.com

 

Darshik
Calcite | Level 5

Is there a way to create a macro for this piece of code?

 

On a side note, how does the "If not" statement work? Although I have used the If-then-else statements now and then, I haven't yet come across of 'If not'. Sorry if my questions come across as silly, I am still catching up on a lot of things in SAS. Thank you for the response by the way 🙂

art297
Opal | Level 21

Just another way of saying:

  if unsb ne 1;

Art, CEO, AnalystFinder.com

 

 

Reeza
Super User

You should also look into how to UPDATE a data set using either a data set or PROC SQL. 

 

Darshik
Calcite | Level 5

Thank you! I will do some quick research on this as well.

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 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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 847 views
  • 0 likes
  • 4 in conversation