<?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: datasets and macro values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103956#M21714</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get what you are saying. I know I could type in more than one statement in the macro var, but there is a lot so I was hoping it could reference a column of a dataset/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Feb 2013 21:28:10 GMT</pubDate>
    <dc:creator>Xamius32</dc:creator>
    <dc:date>2013-02-08T21:28:10Z</dc:date>
    <item>
      <title>datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103952#M21710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is probably an easy question, but here is what I am trying to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Here is dataset&amp;nbsp; i AM using in Macro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;data test123;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;set saslib.megaset;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;numvisits=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*simple enough macro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;%macro Players(Game_ID);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data TestTable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set test123;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if game_pk in (&amp;amp;Game_ID)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then NumVisits+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;%mend Players;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;*Test macro--here is where I want the value to be a column in a dataset (ie column will have a list of lets say 5-10 game_ids which the macro will then assign numvisits+1 for each of those game_Ids.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;%Players(323083); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103952#M21710</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-02-08T21:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103953#M21711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure I completely understand what you are after, but if you remove "numvisits" from your incoming table, the you will have an accumulation on "numvisits" when condition is met. Otherwise, it will be freshed back to '0' every iteration. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103953#M21711</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-02-08T21:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103954#M21712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code doesn't look like it is counting anything even though the variable is called NUMVISITS.&amp;nbsp; Instead it is change the value from 0 to 1 when the value of game_pk matches the passed in value.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it sounds like your question is how to pass in more than one value to test against game_pk.&amp;nbsp; If so then separate the values with spaces in the macro call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data test123;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input game_pk @@ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; numvisits=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1 2 3 4 5 6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let game_id=2 3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data TestTable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set test123;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if game_pk in (&amp;amp;Game_ID) then NumVisits+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; game_pk&amp;nbsp;&amp;nbsp;&amp;nbsp; numvisits&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103954#M21712</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-08T21:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103955#M21713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I mean instead of just checking one ID (323083 in this case), I want to have a list of IDs that I check in the other dataset and add a numvisit to each observation that contains each ID. One ID might show up 5-6 times, one might show&amp;nbsp; up 20 times, etc. Does that make sense?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the %players would ideally have a column name it uses as a list to check.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103955#M21713</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-02-08T21:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103956#M21714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get what you are saying. I know I could type in more than one statement in the macro var, but there is a lot so I was hoping it could reference a column of a dataset/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103956#M21714</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-02-08T21:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103957#M21715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could pull the values from the other dataset into a macro variable.&amp;nbsp; For example if you had another dataset (say GAME_USAGE) that also has a variable named GAME_PK then you could build the macro variable GAME_ID from that dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select distinct game_pk into : game_id separated by ' '&amp;nbsp; from game_usage ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But perhaps instead you want to merge the one file with another. Perhaps the first has details of the games (call it GAME_DEFINITION) and the second represents usage of the games.&amp;nbsp; Now perhaps you have some information that you might want to aggregate into a count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table usage_counts as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select a.game_pk,a.game_name, a.game_type, count(b.game_pk) as numvisits&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from game_definition a left join game_usage b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; on a.game_pk = b.game_pk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; group by 1,2,3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; order by 1,2,3&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103957#M21715</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-08T21:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103958#M21716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that first option might work. This is more of a result of an optimization we are running, so the optimization runs, we see what players it chooses, and once a player is seen twice, optimization doesnt try to pick those players.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103958#M21716</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2013-02-08T21:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: datasets and macro values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103959#M21717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Perhaps you want to update an existing table.&amp;nbsp; Say you had a table (GAME_LIST) with a flag variable (GAME_USED) that was initialized to 0 (false).&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Then you get a list of games that have been used (GAME_USAGE).&amp;nbsp;&amp;nbsp; So you could run an SQL UPDATE statement to set the flag variable to 1 (true) when the game is in the new list;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; update game_list set game_used=1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; where game_pk in (select game_pk from game_usage)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2013 21:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datasets-and-macro-values/m-p/103959#M21717</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-02-08T21:56:34Z</dc:date>
    </item>
  </channel>
</rss>

