<?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: reading value from macro varible in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375672#M90101</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let v1=Pune;
%let v2=umbai;
%let v3=chennai;

data have;
input a$;
datalines;
v1
v2
v3
;
run;

data want;
set have;
b = symget(a);
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;a     b

v1    Pune   
v2    umbai  
v3    chennai
&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 Jul 2017 12:51:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-07-13T12:51:13Z</dc:date>
    <item>
      <title>reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375634#M90078</link>
      <description>&lt;P&gt;hi Expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a small help to get macro value in to data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 macro variable:&lt;/P&gt;&lt;P&gt;% let 1='Pune';&lt;/P&gt;&lt;P&gt;%let 2='mumbai';&lt;/P&gt;&lt;P&gt;% let 3='chennai';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I have a dataset have which has a varibale name A;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input a$;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a output with another variable with assiciated marco variable value, A value should call to macro varible and get macro variable value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ouput :&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pune&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Mumbai&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Chennai&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375634#M90078</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-07-13T11:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375639#M90083</link>
      <description>&lt;P&gt;Single digits cannot be used as macro variable names. Macro variable names can only contain letters, digits and underlines, and must not start with a digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your task, use a value format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
value $indian_cities
  '1' = 'Pune'
  '2' = 'mumbai'
  '3' = 'chennai'
;
run;

data want;
set have;
b = put(a,$indian_cities.);
run;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No macro programming needed at all.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375639#M90083</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T11:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375641#M90084</link>
      <description>&lt;P&gt;Thanks !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose if we would have macro varibale name a,b,c instead of 1,2,3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then how we can get result by doing macro Only.?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375641#M90084</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-07-13T11:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375644#M90086</link>
      <description>&lt;P&gt;You're working with data. The macro language is designed for code creation, not data handling. Forget it.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375644#M90086</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T11:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375652#M90089</link>
      <description>&lt;P&gt;If I have thousand value, then this will be more Hard code values by using proc format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it poosible by doing macro.? when it will check the col1 and varible name and assign the value in to col2.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 11:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375652#M90089</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-07-13T11:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375655#M90091</link>
      <description>&lt;P&gt;Handling a thousand macro variables is inherently more work than a proc format and would be INCREDIBLY stupid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep your thousand values in a dataset (where they belong), and run proc format off that.&lt;/P&gt;
&lt;P&gt;A data step that has your values in a cards; section is MUCH easier to write and maintain than a thousand %lets.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375655#M90091</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T12:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375667#M90099</link>
      <description>&lt;P&gt;As you have already heard, there may be better ways to handle this.&amp;nbsp; But if this is your starting point, it is possible:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;% let v1=Pune;&lt;/P&gt;
&lt;P&gt;%let v2=umbai;&lt;/P&gt;
&lt;P&gt;% let v3=chennai;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input a$;&lt;/P&gt;
&lt;P&gt;datalines;&lt;/P&gt;
&lt;P&gt;v1&lt;/P&gt;
&lt;P&gt;v2&lt;/P&gt;
&lt;P&gt;v3&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can retrieve macro variables based on the value of A in this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;b = symget(a);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, B will have a length of $200.&amp;nbsp; You can always change that with a LENGTH statement after the SET statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that quotes are not advisable when %LET assigns values to macro variables.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375667#M90099</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-13T12:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375671#M90100</link>
      <description>have you checked the values, it will give Pune value in all three rows</description>
      <pubDate>Thu, 13 Jul 2017 12:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375671#M90100</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-07-13T12:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375672#M90101</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let v1=Pune;
%let v2=umbai;
%let v3=chennai;

data have;
input a$;
datalines;
v1
v2
v3
;
run;

data want;
set have;
b = symget(a);
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;a     b

v1    Pune   
v2    umbai  
v3    chennai
&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375672#M90101</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-13T12:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: reading value from macro varible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375673#M90102</link>
      <description>&lt;P&gt;The code works fine, as long as you remove the space after the %.&amp;nbsp; %LET with no space after the % sign.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 12:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reading-value-from-macro-varible/m-p/375673#M90102</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-13T12:51:50Z</dc:date>
    </item>
  </channel>
</rss>

