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.
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
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.
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
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
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 🙂
Just another way of saying:
if unsb ne 1;
Art, CEO, AnalystFinder.com
You should also look into how to UPDATE a data set using either a data set or PROC SQL.
Thank you! I will do some quick research on this as well.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.