<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro Variable in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425188#M13082</link>
    <description>&lt;P&gt;recipient remains same. It is just the content that changes. and minute change like name.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2018 11:42:51 GMT</pubDate>
    <dc:creator>saslearning1</dc:creator>
    <dc:date>2018-01-05T11:42:51Z</dc:date>
    <item>
      <title>Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425175#M13072</link>
      <description>&lt;P&gt;I am a newbie to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have around 100 observations in a variable and i want to take them into macro variable. And then i want to use one name at a time with the loop. That means i am using loop in macro so i use name1 in 1 iteration, then name2 in 2 iteration and name3 in 3rd iteration and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ex: variable Name have 5 names&lt;/P&gt;&lt;P&gt;Smith&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;P&gt;Chen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run macro with parameter name and loop it for five iteration. Then it should take Smith in one iteration and John in second.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425175#M13072</guid>
      <dc:creator>saslearning1</dc:creator>
      <dc:date>2018-01-05T11:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425176#M13073</link>
      <description>&lt;P&gt;What&amp;nbsp;does your macro do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually with this kind of problem it is easier to use simple data step logic, since the data step already 'loops' through the names in the Name variable.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425176#M13073</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-05T11:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425177#M13074</link>
      <description>&lt;P&gt;Though, you can quite easily get the names into a macro variable like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name$;
datalines;
Smith
John
Sam
Michael
Chen
;

proc sql noprint;
	select Name into :names separated by ' '
	from have;
quit;

%put &amp;amp;names.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425177#M13074</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-05T11:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425179#M13076</link>
      <description>Hi Draycut, Thanks for reply.&lt;BR /&gt;&lt;BR /&gt;I am trying to send dynamic e-mail using SAS. where Name will be dynamic in E-mail body. So for this i am taking Name variable into a macro variable.&lt;BR /&gt;&lt;BR /&gt;I will be sending 5 e-mails with the name change in every e-mail.</description>
      <pubDate>Fri, 05 Jan 2018 11:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425179#M13076</guid>
      <dc:creator>saslearning1</dc:creator>
      <dc:date>2018-01-05T11:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425180#M13077</link>
      <description>&lt;P&gt;I never recommend doing this this way.&amp;nbsp; Macro language is not the place to manipulate and process data.&amp;nbsp; For instance, you say you 100 observations which will be names, how long do you think the longest macro variable can be?&amp;nbsp; What about special characters?&amp;nbsp; There are loads of questions which start popping up when doing these lists of data in macro language.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this specific question, the simplest method would be to create (or get your IT group) to create a distribution list of all the email addresses, this list can be modified external from your code, added to, removed from, duplicated etc. and can be of any length.&amp;nbsp; You code then just needs to reference the distribution list, simplifying both your coding, and list maintenance.&amp;nbsp; It would also make finding emails within the email server easier - just find the distro list, could make access easier - i.e. company directories.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:26:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425180#M13077</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-05T11:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425181#M13078</link>
      <description>&lt;P&gt;though I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;, I am curious as to see what your macro look like? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425181#M13078</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-05T11:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425183#M13079</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184860"&gt;@saslearning1&lt;/a&gt; wrote:&lt;BR /&gt;Hi Draycut, Thanks for reply.&lt;BR /&gt;&lt;BR /&gt;I am trying to send dynamic e-mail using SAS. where Name will be dynamic in E-mail body. So for this i am taking Name variable into a macro variable.&lt;BR /&gt;&lt;BR /&gt;I will be sending 5 e-mails with the name change in every e-mail.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is it always the same email, or will the content of the mail change for every recipient? And how is the content of the email created (text with inserts, or reports from datasets, or ....)?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425183#M13079</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-05T11:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425185#M13081</link>
      <description>&lt;P&gt;It should look like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro test(names);&lt;BR /&gt;%do i=2 %to 5;&lt;BR /&gt;data _null_;&lt;BR /&gt;FILE Mailbox TO = abc@gmail.com&lt;BR /&gt;subject=&amp;amp;names.;&lt;BR /&gt;PUT "Dear ALL";&lt;BR /&gt;PUT " My name is";&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%test(names);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my objective is to send five e-mail to abc@gmail with Subject line with name varibale. First e-mail with subject Smith, second with John and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425185#M13081</guid>
      <dc:creator>saslearning1</dc:creator>
      <dc:date>2018-01-05T11:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425188#M13082</link>
      <description>&lt;P&gt;recipient remains same. It is just the content that changes. and minute change like name.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425188#M13082</guid>
      <dc:creator>saslearning1</dc:creator>
      <dc:date>2018-01-05T11:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425191#M13083</link>
      <description>&lt;P&gt;Do not use macro variables for list data. That's what datasets are for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(name);

filename mailbox email "&lt;A class="linkification-ext" title="Linkification: mailto:abc@gmail.com" href="mailto:abc@gmail.com" target="_blank"&gt;abc@gmail.com&lt;/A&gt;" subject="&amp;amp;name";

data _null_;
file mailbox;
put "Dear ALL";
put " My name is &amp;amp;name";
run;

filename mailbox clear;

%mend;

data names;
input name $10.;
cards;
Smith
John
;
run;

data _null_;
set names;
call execute('%test(' !! trim(name) !! ');');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425191#M13083</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-05T11:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425193#M13084</link>
      <description>&lt;P&gt;Thanks KurtBremser.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IT worked file.&lt;/P&gt;&lt;P&gt;Could you please tell me syntax when i have to run for two variables.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425193#M13084</guid>
      <dc:creator>saslearning1</dc:creator>
      <dc:date>2018-01-05T11:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425197#M13086</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184860"&gt;@saslearning1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks KurtBremser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IT worked file.&lt;/P&gt;
&lt;P&gt;Could you please tell me syntax when i have to run for two variables.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Add a second parameter to the macro definition, and use accordingly in the macro body.&lt;/P&gt;
&lt;P&gt;Create the control dataset with two corresponding variables, and expand the call execute accordingly.&lt;/P&gt;
&lt;P&gt;If you need to build a matrix, create two separate datasets (one for each variable), and use proc sql to create the final control dataset as a cartesian product of those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more detailed help, supply your control data in a data step that creates the dataset, similar to my example. Use the "little running man" icon to post code, so that formatting and all characters are preserved as-is.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425197#M13086</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-05T11:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425254#M13088</link>
      <description>&lt;P&gt;Look into CALL EXECUTE() instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can call your macro directly from the data step without having to create macro variables or looping again.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS. Your macro is not correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make a macro first get working code for a single iteration.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Determine what's dynamic and make that into your macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're calling it for each name, then CALL EXECUTE is definitely the route to go.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a fully worked example that would print a report for each age and sex combination in the data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/beb97b1c6d4517dde3b2" target="_blank"&gt;https://gist.github.com/statgeek/beb97b1c6d4517dde3b2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 15:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-Variable/m-p/425254#M13088</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-05T15:29:17Z</dc:date>
    </item>
  </channel>
</rss>

