<?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 modify this macro to make it more flexible? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61196#M13279</link>
    <description>I'd go one step further and move the %global and %let statements down into the macro.  E.g.,&lt;BR /&gt;
[pre]&lt;BR /&gt;
%macro generate_vars(dataset=, library=, varlistname=);&lt;BR /&gt;
  %global &amp;amp;varlistname.;&lt;BR /&gt;
  %let &amp;amp;varlistname.=;&lt;BR /&gt;
  proc sql feedback noprint;&lt;BR /&gt;
    select name into : &amp;amp;varlistname separated by ' '&lt;BR /&gt;
      from dictionary.columns&lt;BR /&gt;
        where libname=upcase("&amp;amp;library") and&lt;BR /&gt;
              memname=upcase("&amp;amp;dataset") &lt;BR /&gt;
    ;&lt;BR /&gt;
  quit;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%generate_vars(dataset=class, library=sashelp, varlistname=myvars);&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;myvars; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Art&lt;BR /&gt;
--------&lt;BR /&gt;
&amp;gt; Hello.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Your code works on SAS 9.1.3.&lt;BR /&gt;
&amp;gt; I've corrected where clause:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %global myvars;&lt;BR /&gt;
&amp;gt; %let myvars=;&lt;BR /&gt;
&amp;gt; %macro generate_vars(dataset=, library=,&lt;BR /&gt;
&amp;gt; varlistname=);&lt;BR /&gt;
&amp;gt; proc sql feedback noprint;&lt;BR /&gt;
&amp;gt; select name into : &amp;amp;varlistname separated by ' '&lt;BR /&gt;
&amp;gt; from dictionary.columns&lt;BR /&gt;
&amp;gt; &lt;B&gt; where libname=upcase("&amp;amp;library") &amp;amp;&lt;BR /&gt;
&amp;gt; memname=upcase("&amp;amp;dataset") &lt;/B&gt;&lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&amp;gt; quit;&lt;BR /&gt;
&amp;gt; %mend;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; options mprint=1;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %generate_vars(dataset=ie, library=mbm,&lt;BR /&gt;
&amp;gt; varlistname=myvars);&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %put &amp;amp;myvars;</description>
    <pubDate>Tue, 03 May 2011 15:33:33 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-05-03T15:33:33Z</dc:date>
    <item>
      <title>How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61192#M13275</link>
      <description>Hi everyone, &lt;BR /&gt;
&lt;BR /&gt;
I created a macro that extracts a list of variables from a dataset. It works, but it is not very flexible.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;%macro generate_vars(dataset=, library=);&lt;BR /&gt;
	%global varlist;&lt;BR /&gt;
	proc sql feedback noprint;&lt;BR /&gt;
		select name into: varlist separated by ' '&lt;BR /&gt;
		from dictionary.columns&lt;BR /&gt;
		where libname=upcase("&amp;amp;library") &amp;amp; memname=upcase("&amp;amp;dataset")&lt;BR /&gt;
	;&lt;BR /&gt;
	quit;&lt;BR /&gt;
%mend generate_vars;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
The reason why I said is is not flexible is because of the global variable "varlist". Everytime I include this macro to extract a list of variables from some dataset, I always must memorize that the macro has a global variable "&lt;B&gt;varlist&lt;/B&gt;" and the variable that contains names of dataset variables is "varlist"! I want to modify the macro so it looks like something below&lt;BR /&gt;
&lt;BR /&gt;
%macro generate_vars(dataset=, library=, varlistname=);&lt;BR /&gt;
&lt;BR /&gt;
So, suppose on Line 500 of my entire SAS program I want to call this macro. Then, I just do something like:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;%generate_vars(dataset=mutual_funds, library=MF, varlistname=anything)&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Then, I can check that I have a list of variables by issuing the %put &amp;amp;anything.&lt;BR /&gt;
&lt;BR /&gt;
How can I discard the global variable "varlist" inside the macro and replace it with an argument to the macro generate_vars? I've tried some but it doesn't work. E.g. the following doesn't work.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;%global myvars;&lt;BR /&gt;
%let myvars=;&lt;BR /&gt;
%macro generate_vars(dataset=, library=, varlistname=);&lt;BR /&gt;
proc sql feedback noprint;&lt;BR /&gt;
          select name into : varlistname separated by ' '&lt;BR /&gt;
          from dictionary.columns&lt;BR /&gt;
          where library=upcase("&amp;amp;library") &amp;amp; dataset=upcase("&amp;amp;dataset")&lt;BR /&gt;
         ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%generate_vars(dataset=A, library=B, varlistname=myvars)&lt;BR /&gt;
%put &amp;amp;myvars;&lt;/B&gt;

Message was edited by: smilingmelbourne</description>
      <pubDate>Tue, 03 May 2011 08:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61192#M13275</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-03T08:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61193#M13276</link>
      <description>Maybe like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
select name into : &lt;B&gt;&amp;amp;varlistname&lt;/B&gt; separated by ' '&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 03 May 2011 09:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61193#M13276</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-03T09:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61194#M13277</link>
      <description>Actually I'd tried that several times but it keeps giving errors, something like the variable "varlistname" is not created within the macro.</description>
      <pubDate>Tue, 03 May 2011 12:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61194#M13277</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-03T12:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61195#M13278</link>
      <description>Hello.&lt;BR /&gt;
&lt;BR /&gt;
Your code works on SAS 9.1.3.&lt;BR /&gt;
I've corrected where clause:&lt;BR /&gt;
&lt;BR /&gt;
%global myvars;&lt;BR /&gt;
%let myvars=;&lt;BR /&gt;
%macro generate_vars(dataset=, library=, varlistname=);&lt;BR /&gt;
proc sql feedback noprint;&lt;BR /&gt;
select name into : &amp;amp;varlistname separated by ' '&lt;BR /&gt;
from dictionary.columns&lt;BR /&gt;
&lt;B&gt; where libname=upcase("&amp;amp;library") &amp;amp; memname=upcase("&amp;amp;dataset") &lt;/B&gt;&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
options mprint=1;&lt;BR /&gt;
&lt;BR /&gt;
%generate_vars(dataset=ie, library=mbm, varlistname=myvars);&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;myvars;</description>
      <pubDate>Tue, 03 May 2011 13:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61195#M13278</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-05-03T13:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61196#M13279</link>
      <description>I'd go one step further and move the %global and %let statements down into the macro.  E.g.,&lt;BR /&gt;
[pre]&lt;BR /&gt;
%macro generate_vars(dataset=, library=, varlistname=);&lt;BR /&gt;
  %global &amp;amp;varlistname.;&lt;BR /&gt;
  %let &amp;amp;varlistname.=;&lt;BR /&gt;
  proc sql feedback noprint;&lt;BR /&gt;
    select name into : &amp;amp;varlistname separated by ' '&lt;BR /&gt;
      from dictionary.columns&lt;BR /&gt;
        where libname=upcase("&amp;amp;library") and&lt;BR /&gt;
              memname=upcase("&amp;amp;dataset") &lt;BR /&gt;
    ;&lt;BR /&gt;
  quit;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%generate_vars(dataset=class, library=sashelp, varlistname=myvars);&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;myvars; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Art&lt;BR /&gt;
--------&lt;BR /&gt;
&amp;gt; Hello.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Your code works on SAS 9.1.3.&lt;BR /&gt;
&amp;gt; I've corrected where clause:&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %global myvars;&lt;BR /&gt;
&amp;gt; %let myvars=;&lt;BR /&gt;
&amp;gt; %macro generate_vars(dataset=, library=,&lt;BR /&gt;
&amp;gt; varlistname=);&lt;BR /&gt;
&amp;gt; proc sql feedback noprint;&lt;BR /&gt;
&amp;gt; select name into : &amp;amp;varlistname separated by ' '&lt;BR /&gt;
&amp;gt; from dictionary.columns&lt;BR /&gt;
&amp;gt; &lt;B&gt; where libname=upcase("&amp;amp;library") &amp;amp;&lt;BR /&gt;
&amp;gt; memname=upcase("&amp;amp;dataset") &lt;/B&gt;&lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&amp;gt; quit;&lt;BR /&gt;
&amp;gt; %mend;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; options mprint=1;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %generate_vars(dataset=ie, library=mbm,&lt;BR /&gt;
&amp;gt; varlistname=myvars);&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %put &amp;amp;myvars;</description>
      <pubDate>Tue, 03 May 2011 15:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61196#M13279</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-05-03T15:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61197#M13280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: #000080; font-size: 9pt; font-family: Courier New;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; vars(data=, dlm=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;( ));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; lib mem ds where keep first name;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; %&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*-- data should exists --*;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; data = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%upcase&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(&amp;amp;data);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; not &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(exist(&amp;amp;data)) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; ERROR:(vars) data=&amp;amp;data does not exists;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%return&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; %&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*-- extract libname and memname and prepare ds options --*;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; lib = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(&amp;amp;data,1,.);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; mem = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(&amp;amp;data,2,.);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &amp;amp;mem = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; mem = &amp;amp;lib;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; lib = WORK;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; where = (libname="&amp;amp;lib" and memname="&amp;amp;mem");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; keep = libname memname name;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; %&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*-- extract var names from sashelp.vcolumn view --*;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; ds = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(open(sashelp.vcolumn(keep=&amp;amp;keep where=&amp;amp;where),is));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &amp;amp;ds=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 9pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; ERROR:(vars) vcolumn of &amp;amp;data cannot be opened;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%return&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%syscall&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; set(ds);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; first = 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%while&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(fetch(&amp;amp;ds))=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 9pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &amp;amp;first &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; first = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%else&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; %&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;amp;dlm;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*;&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="font-size: 9pt; font-family: Courier New;"&gt;trim&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(&amp;amp;name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; ds = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(close(&amp;amp;ds));&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG style="color: #000080; font-size: 9pt; font-family: Courier New;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; vars;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*-- check --*;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; ***%vars(data=sashelp.class)***;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt; ***%vars(data=sashelp.class, dlm=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 9pt;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;(, ))***;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 9pt;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;*-- on log&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;**Name Sex Age Height Weight**&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;**Name, Sex, Age, Height, Weight**&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 9pt;"&gt;--*;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2011 21:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61197#M13280</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2011-05-03T21:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61198#M13281</link>
      <description>Thank you very much for helping</description>
      <pubDate>Thu, 05 May 2011 01:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61198#M13281</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-05T01:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61199#M13282</link>
      <description>Hi chang_y_chung@hotmail.com, how can I post/insert the SAS code like you did so it is easier to read?</description>
      <pubDate>Wed, 11 May 2011 02:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61199#M13282</guid>
      <dc:creator>smilingmelbourne</dc:creator>
      <dc:date>2011-05-11T02:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this macro to make it more flexible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61200#M13283</link>
      <description>Review this prior post for details (consider bookmarking as a FAVORITE too):&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=27609" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=27609&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 11 May 2011 15:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-modify-this-macro-to-make-it-more-flexible/m-p/61200#M13283</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-05-11T15:11:02Z</dc:date>
    </item>
  </channel>
</rss>

