<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33336#M6492</link>
    <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
May be below example is a way to go?&lt;BR /&gt;
&lt;BR /&gt;
data TransposeOutput;&lt;BR /&gt;
  sex=1;&lt;BR /&gt;
  pct2005=25;&lt;BR /&gt;
  cnt2006=50;&lt;BR /&gt;
  pct2007=10;&lt;BR /&gt;
  output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select name into :varlist separated by ' '&lt;BR /&gt;
  from dictionary.columns&lt;BR /&gt;
  where libname='WORK' and memname=%upcase('TransposeOutput')&lt;BR /&gt;
  ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=TransposeOutput;&lt;BR /&gt;
  var &amp;amp;varlist;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
    <pubDate>Fri, 12 Nov 2010 22:03:51 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2010-11-12T22:03:51Z</dc:date>
    <item>
      <title>Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33335#M6491</link>
      <description>I have a SAS dataset created from Proc Freq procedure and transposed. Below is the layout&lt;BR /&gt;
&lt;BR /&gt;
E.g. Proc Freq;&lt;BR /&gt;
	Tables Sex*year;&lt;BR /&gt;
Where year ge 2005 and year le 2007;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
Present Output after transposing by sex&lt;BR /&gt;
Sex	Cnt2005	Cnt2006	Cnt2007	Pct2005	Pct2006	Pct2007&lt;BR /&gt;
Male	 	 	 	 	 	 &lt;BR /&gt;
Female	 	 	 	 	 	 &lt;BR /&gt;
&lt;BR /&gt;
Problem: I need to repeat the analysis for other set of years as needed. E.g. instead of 2005-2007 I may need to use 2000 to 2005 in where statement. How do I modify VAR statement in Proc Print &lt;BR /&gt;
&lt;BR /&gt;
In other words how do I modify the below statement without literally changing them in several proc print statement&lt;BR /&gt;
&lt;BR /&gt;
VAR sex cnt2005 pct2005 cnt2006 pct2006 cnt2007 pct2007;&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Fri, 12 Nov 2010 21:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33335#M6491</guid>
      <dc:creator>rsva</dc:creator>
      <dc:date>2010-11-12T21:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33336#M6492</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
May be below example is a way to go?&lt;BR /&gt;
&lt;BR /&gt;
data TransposeOutput;&lt;BR /&gt;
  sex=1;&lt;BR /&gt;
  pct2005=25;&lt;BR /&gt;
  cnt2006=50;&lt;BR /&gt;
  pct2007=10;&lt;BR /&gt;
  output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select name into :varlist separated by ' '&lt;BR /&gt;
  from dictionary.columns&lt;BR /&gt;
  where libname='WORK' and memname=%upcase('TransposeOutput')&lt;BR /&gt;
  ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=TransposeOutput;&lt;BR /&gt;
  var &amp;amp;varlist;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Fri, 12 Nov 2010 22:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33336#M6492</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-11-12T22:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33337#M6493</link>
      <description>use a var statement like[pre] var sex cnt&amp;amp;from - cnt&amp;amp;to  pct&amp;amp;from - pct&amp;amp;to ;[/pre]where &amp;amp;from and &amp;amp;to are the year range parameters of your macro&lt;BR /&gt;
 &lt;BR /&gt;
luck&lt;BR /&gt;
peterC</description>
      <pubDate>Sat, 13 Nov 2010 16:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33337#M6493</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-13T16:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33338#M6494</link>
      <description>Following Peter's approach you could also use a wildcard as below:&lt;BR /&gt;
&lt;BR /&gt;
proc print data=TransposeOutput;&lt;BR /&gt;
  var sex pct: cnt:;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
This works under the assumption that you always want to print all year-variables in the transposed data set.</description>
      <pubDate>Sat, 13 Nov 2010 23:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33338#M6494</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-11-13T23:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33339#M6495</link>
      <description>Thanks to all who replied to my post. It worked.</description>
      <pubDate>Mon, 15 Nov 2010 16:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/33339#M6495</guid>
      <dc:creator>rsva</dc:creator>
      <dc:date>2010-11-15T16:23:41Z</dc:date>
    </item>
  </channel>
</rss>

