<?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: Defining the number of variables in a transpose macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646342#M78558</link>
    <description>&lt;P&gt;Simply use a wildcard in the VAR statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var var:;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 09 May 2020 06:28:12 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-05-09T06:28:12Z</dc:date>
    <item>
      <title>Defining the number of variables in a transpose macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646339#M78557</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to solve this problem.&lt;/P&gt;&lt;P&gt;I want to run a macro to perform the transpose for many datasets. However, the number of variables that need to be transposed is slightly different across datasets. It could be 39, 40 or 41. Suppose I define those variables as VAR1, VAR2, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;My macro for transpose is like:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;%Macro transpose;&lt;/P&gt;&lt;P&gt;%do i=1999 %to 2018;&lt;/P&gt;&lt;P&gt;proc transpose data=have_&amp;amp;i out=want_&amp;amp;i;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;var&lt;/FONT&gt; var1-var&lt;FONT color="#FF0000"&gt;40&lt;/FONT&gt;;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /*the number of vars is different across each dataset (in each year)*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend transpose;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;I created a dataset below to have the number of variables I need to transpose in each year:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;data num_var;&lt;BR /&gt;input year num_var;&lt;BR /&gt;cards;&lt;BR /&gt;2018 40&lt;BR /&gt;2017 40&lt;BR /&gt;2016 40&lt;BR /&gt;2015 40&lt;BR /&gt;2014 39&lt;BR /&gt;2013 39&lt;BR /&gt;2012 39&lt;BR /&gt;2011 39&lt;BR /&gt;2010 40&lt;BR /&gt;2009 39&lt;BR /&gt;2008 39&lt;BR /&gt;2007 39&lt;BR /&gt;2006 41&lt;BR /&gt;2005 41&lt;BR /&gt;2004 40&lt;BR /&gt;2003 40&lt;BR /&gt;2002 40&lt;BR /&gt;2001 40&lt;BR /&gt;2000 39&lt;BR /&gt;1999 39&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each dataset (in each year), how can I use the value in the dataset num_var to define the VAR option in my transpose macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 04:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646339#M78557</guid>
      <dc:creator>windy</dc:creator>
      <dc:date>2020-05-09T04:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Defining the number of variables in a transpose macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646342#M78558</link>
      <description>&lt;P&gt;Simply use a wildcard in the VAR statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var var:;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 May 2020 06:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646342#M78558</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-09T06:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Defining the number of variables in a transpose macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646343#M78559</link>
      <description>&lt;P&gt;Oh, thank you. It's so simple. I was using PROC SQL and a lot of other stuff. I just make thing complicated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 06:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Defining-the-number-of-variables-in-a-transpose-macro/m-p/646343#M78559</guid>
      <dc:creator>windy</dc:creator>
      <dc:date>2020-05-09T06:45:21Z</dc:date>
    </item>
  </channel>
</rss>

