Discover More Tips and Techniques on This Blog

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 ;
datalines;
2550 Augusta Blvd Apt#203 Fairfield OH 45014
;
run;

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';
run;
  
  • 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 sastest@abc.com subject="Sending Email using SAS" from=abctest@gmail.com' 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';
run;
quit;

Disclosure:

In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers. My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.