<?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: Using first. and last. with macro elements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92730#M19553</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;Does this make sense? Any ideas?&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;No.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Show example data using the have/need scenario.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Mar 2013 17:13:18 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2013-03-29T17:13:18Z</dc:date>
    <item>
      <title>Using first. and last. with macro elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92729#M19552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have some data which has different players assigned to different clusters, along with a do loop for each one of the clusters which is stored in the macro language. So basically, right now, I have a do loop which says "do the following from 1 to C" where C is the macro number (ranges from 1 to 8.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I want to add up the number of times a player appears in the particular cluster, and also how many times they appear overall. So the following code is a basis. I cant just look at the observations in C because then I wouldnt know how many times a player would appear total. I dont know how to use a first. in a similar fashion when the cluster number will change (the variable cluster will vary for each player. So lets say when a player is at home, he is in cluster 4, and when he goes on the road he might appear in cluster 5 and so on. So I cant actually use the code as it is now).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this make sense? Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;data megasetfinallast_&amp;amp;&amp;amp;K&amp;amp;&amp;amp;C;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;set megasetfinal1;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;by player_id cluster game_date;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if first.cluster then numcluster=0;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if first.player_id then numtotal=0;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;numtotal+1;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;numcluster+1;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;retain numcluster;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if last.player_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if numcluster&amp;gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;run;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Mar 2013 17:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92729#M19552</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-03-29T17:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using first. and last. with macro elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92730#M19553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;Does this make sense? Any ideas?&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;No.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Show example data using the have/need scenario.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Mar 2013 17:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92730#M19553</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-03-29T17:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using first. and last. with macro elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92731#M19554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Cluster&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Player_ID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Game_date&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;numcluster&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;numtotal&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/05/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/06/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/07/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/08/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/09/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/10/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;04/11/12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And so forth.So lets say for cluster 2, I only want the player for the obs. in cluster 2, the last observation would have numcluster to be 4 and numtotal to be 7. Numcluster will only increase when cluster = C (the particular iteration of the do loop.) so at C=1, numcluster gets added by 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get it to do if cluster=&amp;amp;&amp;amp;C then numcluster+1 but it doesnt seem to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Mar 2013 17:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92731#M19554</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-03-29T17:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using first. and last. with macro elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92732#M19555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should add the do loop looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do C=1 %to &amp;amp;Num_Clusters;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then Num_Clusters is found in the macro call with a value of 8.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Mar 2013 18:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92732#M19555</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-03-29T18:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using first. and last. with macro elements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92733#M19556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not clear at all.&amp;nbsp; &lt;/P&gt;&lt;P&gt;On the one hand it sounds like you want to GENERATE data based on some macro variable.&amp;nbsp; If that is the case write a date step.&amp;nbsp; You should be able to write the data step using data step DO looping and just set the bounds of the loops using the macro variables.&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do c= 1 to &amp;amp;num_clusters;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand it sounds like you want to summarize some existing data and group by variables in the data. In that case use PROC SUMMARY or possible PROC TABULATE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Mar 2013 01:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-first-and-last-with-macro-elements/m-p/92733#M19556</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-30T01:29:32Z</dc:date>
    </item>
  </channel>
</rss>

