<?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: Help with SAS Macro variable that is a list of regular data set variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117605#M293146</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your help! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Nov 2012 16:20:32 GMT</pubDate>
    <dc:creator>roman_makordey</dc:creator>
    <dc:date>2012-11-06T16:20:32Z</dc:date>
    <item>
      <title>Help with SAS Macro variable that is a list of regular data set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117602#M293143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody!&lt;/P&gt;&lt;P&gt;I was wondering if somebody could help me with my problem.&lt;/P&gt;&lt;P&gt;Basically I have a SAS macro variable which is a list of the variables that are present in a SAS data set and I am cycling through those variables and would like to say cap those variables that are &amp;gt; 254.&lt;/P&gt;&lt;P&gt;Here is the sample code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..... blah-blah-blah... the list of the variable names are put into the sas macro variable called modelvars.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro get_capped();&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set b (obs=100);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let j = 1;&lt;/P&gt;&lt;P&gt; %do %until (%scan(&amp;amp;modelvars.,&amp;amp;j,%str( ))= %str());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let var=%upcase(%scan(&amp;amp;modelvars.,&amp;amp;j,%str( )));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &lt;SPAN style="color: #ff0000;"&gt;&amp;amp;var. &amp;gt; 254 %then &amp;amp;var. = 254;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let j = %eval(&amp;amp;j +1);&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend get_capped;&lt;/P&gt;&lt;P&gt;%get_capped;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The RED code is the one that I am stuck on. I know that the variable name resolved to TEXT, but how do I make SAS compiler treat that text as if it was the name of the actual variable in the data set and then cap that variable?&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2012 21:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117602#M293143</guid>
      <dc:creator>roman_makordey</dc:creator>
      <dc:date>2012-11-05T21:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SAS Macro variable that is a list of regular data set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117603#M293144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On the one hand, you are very close to having a working program.&amp;nbsp; Getting rid of two % should make it work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if &amp;amp;var. &amp;gt; 254 then &amp;amp;var. = 254;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand, this could be solved much more simply, without the need to define a macro.&amp;nbsp; Consider:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set b (obs=100);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array cap_me {*} &amp;amp;modelvars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _i_=1 to dim(cap_me);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if cap_me{_i_} &amp;gt; 254 then cap_me{_i_} = 254;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2012 22:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117603#M293144</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-11-05T22:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SAS Macro variable that is a list of regular data set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117604#M293145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try the code below:&lt;/P&gt;&lt;P&gt;%macro get_capped();&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set b (obs=100);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let j = 1;&lt;/P&gt;&lt;P&gt; %do %until (%scan(&amp;amp;modelvars.,&amp;amp;j,%str( ))= %str());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let var=%upcase(%scan(&amp;amp;modelvars.,&amp;amp;j,%str( )));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &amp;amp;var. &amp;gt; 254 then &amp;amp;var. = 254;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let j = %eval(&amp;amp;j +1);&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend get_capped;&lt;/P&gt;&lt;P&gt;%get_capped;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2012 22:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117604#M293145</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-11-05T22:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SAS Macro variable that is a list of regular data set variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117605#M293146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your help! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 16:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro-variable-that-is-a-list-of-regular-data-set/m-p/117605#M293146</guid>
      <dc:creator>roman_makordey</dc:creator>
      <dc:date>2012-11-06T16:20:32Z</dc:date>
    </item>
  </channel>
</rss>

