BookmarkSubscribeRSS Feed
bncoxuk
Obsidian | Level 7

Hi,

I just found a piece of code online, and tested it, and it worked. The code is below. My question is:

FILENAME myemail EMAIL TO="abc@gmail.com" FROM="BILL" IMPORTANCE="HIGH" SUBJECT="A test";

DATA _NULL_;

  FILE myemail;

  PUT "Please go to place A";

RUN;;

FILENAME myemail CLEAR;

If there are 5 places: A, B, C, D and E. I am interested to know how I can adapt the code so that:

1) the email will be sent every 1 hour;

2) each email will tell the random place to go (the above code tells to go to place A);

3) any place should not be visited twice.

Thanks a lot.

3 REPLIES 3
art297
Opal | Level 21

Some critical questions are:

1. How many people will this be going to?

2. Do you want to have approximately equal numbers assigned to each room each hour?

One possibility, assuming that it will be going to multiple people and you do want random assignment rather than simply random selection, would be to do all of the assignments up front, store them in the file, and then simply select the nth selection for each recipient each hour.

bncoxuk
Obsidian | Level 7

Hi art297,

1. How many people will this be going to?

Suppose the exactly same email will be sent to 3 people.

2. Do you want to have approximately equal numbers assigned to each room each hour?

Each time, the same email will be sent to all 3 people. The contents are exactly the same.

art297
Opal | Level 21

There are more direct methods, but I think the following may be easy to understand:

/*Create a file called rooms and, in it, assign the 5 rooms and a randomly generated number for each*/

data rooms;

  input room $;

  order=ranuni(0);

  cards;

A

B

C

D

E

;

/*sort the file by the randomly assigned number*/

proc sort data=rooms;

  by order;

run;

/*if your emails are going to go out every hour beginning at 1pm, assign the numbers*/

/*13 thru 17 to the randomly ordered rooms*/

data rooms;

  if _n_ eq 1 then hour=12;

  set rooms;

  hour+1;

run;

/*incorporate your email code in this datastep which selects each record*/

/*based on the hour of day and use windows are SAS scheduler to run the*/

/*program each hour*/

data select;

  set rooms (where=(hour=hour(timepart(datetime()))));

   *your email generating code;

run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 650 views
  • 3 likes
  • 2 in conversation