<?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: Multiple values for a &amp;quot;variable&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51362#M10730</link>
    <description>Sort of. You can't directly have a variable have more than value at a time AFAIK, so you end up with a few different solutions:&lt;BR /&gt;
&lt;BR /&gt;
1) A text variable with all values in the cell ie responsible fielder= "Player1, Player2"&lt;BR /&gt;
2) Multiple variables ie resposiblefielder1 responsiblefielder2 etc..&lt;BR /&gt;
3) Multiple records for each hit with an identifier to the fielder ie&lt;BR /&gt;
responsiblefielder=player1 record=1&lt;BR /&gt;
responsiblefielder=player2 record=2&lt;BR /&gt;
&lt;BR /&gt;
Which method you choose depends on what you plan to do next with the field and how it will affect other fields and calculations.  &lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Reeza</description>
    <pubDate>Fri, 15 Apr 2011 17:12:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2011-04-15T17:12:35Z</dc:date>
    <item>
      <title>Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51361#M10729</link>
      <description>Hello,&lt;BR /&gt;
I have the following issue:&lt;BR /&gt;
&lt;BR /&gt;
Under certain scenarios, I have a data set where several different people should be responsible for a situation.  So, if the variable &lt;BR /&gt;
&lt;BR /&gt;
[pre] PlayResult = 'hit'[/pre]&lt;BR /&gt;
&lt;BR /&gt;
there can be anywhere from 1 to 4 fielders responsible for this.  I would then want to have a variable, "ResponsibleFielder" be able to have whatever fielders should be responsible, in other words, i would want the variable to be able to reference multiple values, where the number of values can change from data line to data line.  A 3-dimensional variable for my data set if you will.&lt;BR /&gt;
&lt;BR /&gt;
So for example, if [pre]PlayResult = 'hit'[/pre] for the first data line, i might have [pre]ResponsibleFielder= Player1, Player2, Player3[/pre] and then for the second data line have [pre]ResponsibleFielder= Player7, Player12[/pre] and for the third dataline have [pre]ResponsibleFielder= Player14[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Is this possible?

Message was edited by: CharlesR</description>
      <pubDate>Fri, 15 Apr 2011 16:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51361#M10729</guid>
      <dc:creator>CharlesR</dc:creator>
      <dc:date>2011-04-15T16:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51362#M10730</link>
      <description>Sort of. You can't directly have a variable have more than value at a time AFAIK, so you end up with a few different solutions:&lt;BR /&gt;
&lt;BR /&gt;
1) A text variable with all values in the cell ie responsible fielder= "Player1, Player2"&lt;BR /&gt;
2) Multiple variables ie resposiblefielder1 responsiblefielder2 etc..&lt;BR /&gt;
3) Multiple records for each hit with an identifier to the fielder ie&lt;BR /&gt;
responsiblefielder=player1 record=1&lt;BR /&gt;
responsiblefielder=player2 record=2&lt;BR /&gt;
&lt;BR /&gt;
Which method you choose depends on what you plan to do next with the field and how it will affect other fields and calculations.  &lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Reeza</description>
      <pubDate>Fri, 15 Apr 2011 17:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51362#M10730</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-04-15T17:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51363#M10731</link>
      <description>What do you mean by multiple records?  Does this create a new line of data?</description>
      <pubDate>Fri, 15 Apr 2011 17:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51363#M10731</guid>
      <dc:creator>CharlesR</dc:creator>
      <dc:date>2011-04-15T17:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51364#M10732</link>
      <description>Yes, you would have multiple lines for each play result with multiple players.</description>
      <pubDate>Fri, 15 Apr 2011 17:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51364#M10732</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-04-15T17:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51365#M10733</link>
      <description>It sounds to me like you want to build yourself a multi-dimensional array -- perhaps something like the following:&lt;BR /&gt;
dimension 1=inning&lt;BR /&gt;
dimension 2=at bat (seq number of at-bat in the inning) &lt;BR /&gt;
dimension 3=batter&lt;BR /&gt;
dimension 4=multimensional array of defensive players involved in play&lt;BR /&gt;
dimension 5=result&lt;BR /&gt;
&lt;BR /&gt;
That's off the top of my head.  But the problem sounds as if it is soluble by building arrays.  Or hash tables instead of arrays.</description>
      <pubDate>Fri, 15 Apr 2011 17:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51365#M10733</guid>
      <dc:creator>Benjy</dc:creator>
      <dc:date>2011-04-15T17:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51366#M10734</link>
      <description>Don't want to go the array route because the data set is huge, and this would be a small part of it.&lt;BR /&gt;
&lt;BR /&gt;
What's a hash table?</description>
      <pubDate>Fri, 15 Apr 2011 20:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51366#M10734</guid>
      <dc:creator>CharlesR</dc:creator>
      <dc:date>2011-04-15T20:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51367#M10735</link>
      <description>An array will just reference multiple variables and a hash table will bring info in from another table.  &lt;BR /&gt;
&lt;BR /&gt;
A hash table and array are both temporary structures, they're not ways to store your information. &lt;BR /&gt;
&lt;BR /&gt;
Are you asking about how to create a table to store your information or using it?&lt;BR /&gt;
&lt;BR /&gt;
Like I mentioned before the optimal way to store the data depends on how you'd like to use it.</description>
      <pubDate>Fri, 15 Apr 2011 20:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51367#M10735</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-04-15T20:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51368#M10736</link>
      <description>I was looking for a data set to store it.  I'm thinking the 2nd suggestion you made, using multiple variables to show each fielder is going to be the way to go.  &lt;BR /&gt;
&lt;BR /&gt;
So that leads to a new question: how do i take each of the results in the fieldingbyposition column and transpose them to new variables.  I'm going to post it as a new thread in this same section.&lt;BR /&gt;
&lt;BR /&gt;
Here's the example: [pre]&lt;BR /&gt;
z	BT	BBV	DP	Bat	Res	field	&lt;BR /&gt;
23	5	1	N	R	Hit	0	&lt;BR /&gt;
23	5	1	N	R	Out	5	&lt;BR /&gt;
23	5	1	Y	L	Hit	0	&lt;BR /&gt;
23	5	1	Y	L	Out	5	&lt;BR /&gt;
23	5	1	Y	L	Out	9	&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
The first two line of data show one scenario with 2 different fielders, 0 &amp;amp; 5.  The next 3 lines show a different scenario with 3 fielders, 0, 5 &amp;amp; 9.  I then want it to look like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
z	BT	BBV	DP	Bat	Res	field1	field2 field3&lt;BR /&gt;
23	5	1	N	R	Hit	0	5	&lt;BR /&gt;
23	5	1	Y	L	Hit	0	5	9	&lt;BR /&gt;
[/pre]&lt;BR /&gt;
What do i need to do to make this work?</description>
      <pubDate>Fri, 15 Apr 2011 21:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51368#M10736</guid>
      <dc:creator>CharlesR</dc:creator>
      <dc:date>2011-04-15T21:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for a "variable"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51369#M10737</link>
      <description>OK.That is easy.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 input z	BT	BBV	DP $	Bat $	Res	$ field	;&lt;BR /&gt;
cards;&lt;BR /&gt;
23	5	1	N	R	Hit	0	&lt;BR /&gt;
23	5	1	N	R	Out	5	&lt;BR /&gt;
23	5	1	Y	L	Hit	0	&lt;BR /&gt;
23	5	1	Y	L	Out	5	&lt;BR /&gt;
23	5	1	Y	L	Out	9	&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data temp;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 if res = 'Hit' then count+1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 by count ;&lt;BR /&gt;
 length fieldres $ 200;&lt;BR /&gt;
 retain fieldres num;&lt;BR /&gt;
 nobs+1;&lt;BR /&gt;
 if first.count then do; &lt;BR /&gt;
                       call missing (fieldres);&lt;BR /&gt;
                       num=nobs;&lt;BR /&gt;
                     end;&lt;BR /&gt;
 fieldres=catx(' ',fieldres,field);&lt;BR /&gt;
 if last.count then do;&lt;BR /&gt;
                   set temp point=num;&lt;BR /&gt;
                   output;&lt;BR /&gt;
                  end;&lt;BR /&gt;
 drop field nobs count;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 18 Apr 2011 04:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-values-for-a-quot-variable-quot/m-p/51369#M10737</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-18T04:00:12Z</dc:date>
    </item>
  </channel>
</rss>

