Search This Blog


Saturday, April 10, 2010

Write a Letter using SAS/ Emailing with SAS

SAS can do many things which most of us don’t have a clue. Here is one example….

Writing a letter:

filename formltr 'C:\Documents and Settings\sreddy\Desktop\formltr.rtf';

data address;
infile datalines;
input @ 1 stno
 @ 6 lane $12.
@19 aptno $7.
@27 city $9.
@37 state $2.
@40 zip ;
2550 Augusta Blvd Apt#203 Fairfield OH 45014

data _null_;
retain lm 5;
set address;
file formltr;* print notitles;
put _page_;
adr1 = trim(stno) ' ' trim(lane);
put @lm adr1;
adr2 = trim(aptno);
put @lm adr2;
adr3 = trim(city) ||', '|| trim(state) ||' '|| trim(zip);
put @lm adr3;
adr4 = trim('Dear')|| ' ' ||trim('SAS') || ' ' || trim('Users,');
put / @lm adr4;
put / @lm 'StudySAS Blog offers a lot of information regarding tips and tutorials on various topics ' ;
put @lm 'in SAS. It covers basics to get started to more in-depth topics like Macros and Proc SQL.';
put @lm 'It is a great site to browse to help broaden and deepen your SAS knowledge in a variety';
put @lm 'of areas.';
put / @lm 'Thanks for visiting StudySAS Blog. ';
put //// @lm 'Sarath Annapareddy';
  • lm: represents left margin
  • / : forward slash symbol ( / ) skips a line.
  • If you want to skip ‘N’ number of lines use ‘N’ number of flashes after the PUT statement.
  • The trim function and concatenation operator (||) are important here because without these you will get extra spaces which we probably don't want see in our letter.
The Above SAS program will create a rtf in the specified location with the following information.

Emailing with SAS

How to send an email using SAS:

filename mymail email subject="Sending Email using SAS"' attach="C:\Documents and Settings\sreddy\Desktop\formltr.rtf";

data _null_;
file mymail;
put 'Hello there, Please review the attached letter.';
put 'Thanks,';
put 'Sarath';


Post a Comment