The License Check Program was developed as a warning system to remind you when the license was about to expire. This program will check the expiration date for the SAS Session running the program. If any products are within the defined warning period, the program will send an e-mail to the users defined in the program. This may help the SAS Administrator remember to update the server with the new SID before the SAS license expires.
You can schedule the program to run regularly on the machine, e.g. once a month or once every 2 weeks.
The program contains a macro, which takes two optional parameters:
Warn - The warning period in days. Default: 30
From - The sender of the e-mail
Here is an example of how to call the macro program:
%SidCheck(Warn=15, From=sasadmin@the.sas.com);
The program will locate the recipients of the warning mails by using a SAS data set WORK.EMAILS. This data set must contain a variable named MAILADR. An optional variable named NAME is allowed. MAILADR must contain the SMTP mail address of the recipient. NAME must contain the real name of the recipient.
In order for the program to be able to send the e-mails, you have to configure SAS to use an SMTP mail server. To do so, start SAS with the following two options in your configuration file:
EMAILSYS=SMTP
EMAILHOST=your.smtp.server.com
/* License Check Program */
Data Work.Emails;
length mailadr name $ 25;
infile datalines delimiter=',' missover;
input mailadr $ name $ ;
datalines;
sasadmin@the.sas.com, Administrator
;
run;
Options noMPrint noSource noNotes;
%macro SidCheck(Warn=30, From=);
%Local TermOk;
%If %Datatyp(&Warn) EQ CHAR %Then %Do;
%Put * ******************************************* *;
%Put * * Warning period is not numeric. * *;
%Put * * Default warning period of 30 used. * *;
%Put * ******************************************* *;
%let Warn=30;
%End;
Proc SQL;
Create Table Work._Present As
Select * From Dictionary.Tables
Where LibName EQ 'WORK' And
MemName EQ 'EMAILS' ;
Quit;
Data _Null_;
If Not Present Then Do;
Put '* ******************************************* *' /
'* * No recipient defined! * *' /
'* * Please create the dataset WORK.EMAILS * *' /
'* * Program will now terminate!!! * *' /
'* ******************************************* *' ;
Abort Return 4;
End;
Set Work._Present NObs=Present;
Stop;
Run;
Filename cmds pipe "hostname";
Data _Null_;
Infile cmds;
Input;
Call SymPut('Host',_infile_);
Run;
FileName SidInfo Catalog 'Work.SidInfo.SidInfo.Source';
Proc Printto Log=SidInfo New;
Run;
Proc Setinit;
Run;
Proc Printto;
Run;
Data Work.Products;
Length Product $75;
Format Expire Date9.;
Infile SidInfo Truncover;
Input Line $Char86.;
If Index(Line,'---') Then Do;
Product=SubStr(Line,4,71);
Expire=Input(SubStr(Line,76,9),Date9.);
If Expire-Today() LE &Warn Then Output;
End;
Else Delete;
Drop Line;
Run;
Data _Null_;
If Not Present Then Do;
Put '* ******************************************* *' /
'* * No SAS Products are about to expire. * *' /
'* * Program will now terminate. * *' /
'* ******************************************* *';
Call Symput('TermOK','OK');
End;
Else Do;
Put '* ******************************************* *' /
'* * Some SAS Products are about to expire. * *' /
'* * Program will now send emails. * *' /
'* ******************************************* *';
End;
Set Work.Products NObs=Present;
Stop;
Run;
%If "&TermOK" NE "OK" %then %Do;
Filename MyMail EMail
%If "&From" NE "" %Then From="&From";
;
Data _Null_;
File MyMail;
%If "&From" NE "" %Then %Do;
Put "!EM_SENDER! &From";
%End;
Put "!EM_SUBJECT! SAS Products are about to expire on server &Host!" ;
Do I=1 to NoProd;
Set Work.Products Point=I NObs=NoProd;
If I EQ 1 Then Do;
Put 'Hi, '
// "The following products are about to expire on server: &Host"
// @1 "Expire" / @1 "Date" @12 "Product" /;
End;
Put @1 Expire @12 Product ;
End;
Do I=1 to NoMail;
Set Work.EMails Point=I NObs=NoMail;
If Name NE " " Then
Put "!EM_TO! " Name "<" MailAdr ">";
Else
Put "!EM_TO! " MailAdr;
Put '!EM_SEND! ';
End;
Put '!EM_ABORT! ';
Stop;
Run;
%End;
%Mend;
%SidCheck(Warn=15, From= sasadmin@the.sas.com);