<?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: Is it possible to make a list in macro statements? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162909#M31562</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if the following is what you are trying to do but, if it is, this would be one way to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date date9. x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;01jan1990 1&lt;/P&gt;&lt;P&gt;02jan1990 2&lt;/P&gt;&lt;P&gt;01jan1991 1&lt;/P&gt;&lt;P&gt;02jan1991 2&lt;/P&gt;&lt;P&gt;01jan1992 1&lt;/P&gt;&lt;P&gt;02jan1992 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct catt('have',year(date)),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catt('when (',year(date),') output have',year(date),';')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :years separated by ' ',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :out separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;years;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select (year(date));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 May 2014 21:46:27 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2014-05-16T21:46:27Z</dc:date>
    <item>
      <title>Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162905#M31558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a small question actually, and I am asking that to widen my knowledge of sas. So, I want to break my data set year by year in different datasets. This is the small code that I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let yearvar=1991;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have&amp;amp;yearvar;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if year(date)=&amp;amp;yearvar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, It is just enough to change the year every time to get for every year. However, I was thinking if there is a way to make a list in the %let statement, that sas does the thing for every one in the list. I could not find such thing in my searches, But I think it might be useful in some cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any one has any idea?&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 18:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162905#M31558</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-05-16T18:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162906#M31559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without knowing what comes next after the data step, my guess is that you really want to use a BY statement in whatever PROC follows, and then all this splitting of data sets is unnecessary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you could certainly loop through all years in &amp;amp;yearvar and create multiple data sets if you wanted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 19:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162906#M31559</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-05-16T19:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162907#M31560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you could create a macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input date mmddyy10.;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;cards;&lt;BR /&gt;1/1/2001&lt;BR /&gt;2/1/2001&lt;BR /&gt;1/1/2002&lt;BR /&gt;1/1/2006&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt; select distinct year(date) into :year separated by ' '&lt;BR /&gt;&amp;nbsp; from have;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%macro test;&lt;BR /&gt;%do i=1 %to %sysfunc(countw(&amp;amp;year));&lt;BR /&gt;%let n=%scan(&amp;amp;year,&amp;amp;i);&lt;BR /&gt; data have&amp;amp;n;&lt;BR /&gt;&amp;nbsp; set have(where=(year(date)=&amp;amp;n));&lt;BR /&gt; run;&lt;BR /&gt; %end;&lt;BR /&gt; %mend;&lt;BR /&gt; %test&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 19:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162907#M31560</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2014-05-16T19:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162908#M31561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Company $ Year; &lt;BR /&gt;datalines;&lt;BR /&gt;A 2001&lt;BR /&gt;A 2002&lt;BR /&gt;A 2003&lt;BR /&gt;A 2004&lt;BR /&gt;B 2001&lt;BR /&gt;B 2002&lt;BR /&gt;B 2003&lt;BR /&gt;C 2001&lt;BR /&gt;C 2002&lt;BR /&gt;C 2003&lt;BR /&gt;C 2004&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;%macro yr;&lt;BR /&gt;%do i=2001 %to 2004;&lt;BR /&gt;data year&amp;amp;i;&lt;BR /&gt;set have(where=(year=&amp;amp;i));&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend yr;&lt;BR /&gt;%yr;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 19:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162908#M31561</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-05-16T19:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162909#M31562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if the following is what you are trying to do but, if it is, this would be one way to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date date9. x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;01jan1990 1&lt;/P&gt;&lt;P&gt;02jan1990 2&lt;/P&gt;&lt;P&gt;01jan1991 1&lt;/P&gt;&lt;P&gt;02jan1991 2&lt;/P&gt;&lt;P&gt;01jan1992 1&lt;/P&gt;&lt;P&gt;02jan1992 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct catt('have',year(date)),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catt('when (',year(date),') output have',year(date),';')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :years separated by ' ',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :out separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;years;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select (year(date));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 May 2014 21:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162909#M31562</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-05-16T21:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162910#M31563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are multiple ways of how you can split a single data set into multiple ones - but it's most of the time not a good idea. As &lt;A __default_attr="9481" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; points out most tasks are better done using by group processing.&lt;/P&gt;&lt;P&gt;Can you explain us why you want to split the data set?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 May 2014 00:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162910#M31563</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-05-17T00:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162911#M31564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Patrick,&lt;/P&gt;&lt;P&gt;Actually at first I decided to do so because the whole data set was too large and other than losing track, running it would also take a lot of time. Also, It made me to work more on my macro programming skills!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 15:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162911#M31564</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-05-22T15:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162912#M31565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot linlin,&lt;/P&gt;&lt;P&gt;This was exactcly what I wanted to learn. Actually I was not aware of&amp;nbsp; " select into " and after reading some documents I see how powerful it is.&lt;/P&gt;&lt;P&gt;thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 15:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162912#M31565</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-05-22T15:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to make a list in macro statements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162913#M31566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, Arthur. Actually this is what I was looking for!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 15:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-make-a-list-in-macro-statements/m-p/162913#M31566</guid>
      <dc:creator>Shayan2012</dc:creator>
      <dc:date>2014-05-22T15:03:48Z</dc:date>
    </item>
  </channel>
</rss>

