<?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: How to automatically define macro variables (names and values) based on a sas table contents in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468176#M285399</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/95727"&gt;@Elle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So simple, it's embarrassing.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This may be obvious but you really want to make sure with an approach like this that the variable holding the macro variable name is unique even considering case: "name" "Name" "nAme" would all have the value sent to the same macro variable and you could spend a fair amount of time debugging values when only 10 actual different&amp;nbsp;macro variables are created when you expect 11 (or 15 or ...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And not to mention accidently using a name that would duplicate an already existing macro variable and replacing it's value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please don't ask me how I know &lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jun 2018 19:59:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-06-06T19:59:10Z</dc:date>
    <item>
      <title>How to automatically define macro variables (names and values) based on a sas table contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468087#M285394</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a sas table looking like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table;
   input environment:$5. varname:$10. value:$100.;
   datalines;
prod sanroot /data/sasdata/prod
prod macropath /data/sasdata/prod/macros
;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need an ingenious way of defining an interactive list of macro variables, where for each row in the above table, 'varname' represents the macro's name and 'value' the macro's contents, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let sanroot=/data/sasdata/prod
%let macropath=/data/sasdata/prod/macros&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Please ignore column 'environment' - there's a previous condition where I filter the table by environment.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I already have a function determining the nobs of the table.&lt;/P&gt;&lt;P&gt;Is there a magic function that can do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I'm aware there are other methods - reading all values for 'varname' in a list using proc sql with into: and then do a loop.&lt;/P&gt;&lt;P&gt;I am looking for an intelligent alternative of a&amp;nbsp;a few line(s) of code. I'm wondering if it's possible.&lt;/P&gt;&lt;P&gt;Basically I'm looking for something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsid=%sysfunc(open(table));&lt;BR /&gt;%do i=1 %to &amp;amp;nobs;
  %let %sysfunc(getvarc(&amp;amp;dsid.,2))=%sysfunc(getvarc(&amp;amp;dsid.,3));
%end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 15:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468087#M285394</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2018-06-06T15:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically define macro variables (names and values) based on a sas table contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468091#M285395</link>
      <description>&lt;P&gt;Use call symput in the data step that creates the dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput(varname,value);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jun 2018 15:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468091#M285395</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-06T15:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically define macro variables (names and values) based on a sas table contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468099#M285396</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;The table already exists, it's provided by the business. I put a data step in here for illustration purposes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 15:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468099#M285396</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2018-06-06T15:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically define macro variables (names and values) based on a sas table contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468100#M285397</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

set sashelp.class;

call symputx(name, age);

run;

%put &amp;amp;Alfred;
%put &amp;amp;Fred;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;CALL SYMPUTX - X trims spaces and you can set it up as local/global.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 15:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468100#M285397</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-06T15:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically define macro variables (names and values) based on a sas table contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468102#M285398</link>
      <description>&lt;P&gt;So simple, it's embarrassing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 15:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468102#M285398</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2018-06-06T15:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically define macro variables (names and values) based on a sas table contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468176#M285399</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/95727"&gt;@Elle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So simple, it's embarrassing.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This may be obvious but you really want to make sure with an approach like this that the variable holding the macro variable name is unique even considering case: "name" "Name" "nAme" would all have the value sent to the same macro variable and you could spend a fair amount of time debugging values when only 10 actual different&amp;nbsp;macro variables are created when you expect 11 (or 15 or ...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And not to mention accidently using a name that would duplicate an already existing macro variable and replacing it's value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please don't ask me how I know &lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 19:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-define-macro-variables-names-and-values/m-p/468176#M285399</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-06T19:59:10Z</dc:date>
    </item>
  </channel>
</rss>

