<?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: data set with all possible combinations of variable values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558875#M10192</link>
    <description>&lt;P&gt;thanks, Paige, good point the first column in the "R" example is jus the row number that R inserts - it is confusing apologies&lt;/P&gt;&lt;P&gt;for the data set I sent earlier the output I'd want would be&lt;/P&gt;&lt;PRE&gt;RAJ 20 &amp;nbsp;&lt;BR /&gt;RAJ 30 &amp;nbsp;&lt;BR /&gt;RAJ 40&lt;BR /&gt;RAJ 90 &lt;BR /&gt;RAVI 20 &amp;nbsp;&lt;BR /&gt;RAVI 30 &amp;nbsp;&lt;BR /&gt;RAVI 40&lt;BR /&gt;RAVi 90  
JOHN 20 &amp;nbsp;&lt;BR /&gt;JOHN 30 &amp;nbsp;&lt;BR /&gt;JOHN 40&lt;BR /&gt;JOHN 90 
JOSEPH 20 &amp;nbsp;&lt;BR /&gt;JOSEPH 30 &amp;nbsp;&lt;BR /&gt;JOSEPH 40&lt;BR /&gt;JOSEPH 90  
run;&lt;/PRE&gt;&lt;P&gt;thanks again for all your advice&lt;/P&gt;</description>
    <pubDate>Wed, 15 May 2019 12:00:50 GMT</pubDate>
    <dc:creator>bnorth66</dc:creator>
    <dc:date>2019-05-15T12:00:50Z</dc:date>
    <item>
      <title>data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558855#M10185</link>
      <description>&lt;P&gt;is there a way to take a data set that contains 2 categorical variables and create an output data set with a single line for all possible combinations of those two variables (maybe I'd have to create data sets with duplicates first ? not sure)&lt;/P&gt;&lt;P&gt;if it makes it clearer in R this would be done as follows using the mtcars data (all combinatios returned) - many thanks&lt;/P&gt;&lt;PRE&gt;expand.grid(unique(mtcars$cyl),unique(mtcars$gear))
Var1 Var2
1 6 4
2 4 4
3 8 4
4 6 3
5 4 3
6 8 3
7 6 5
8 4 5
9 8 5&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 10:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558855#M10185</guid>
      <dc:creator>bnorth66</dc:creator>
      <dc:date>2019-05-15T10:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558860#M10187</link>
      <description>&lt;P&gt;Do you mean to do a frequency count for the distinct combinations? Most easily done in SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select var1, var2, count(*) as count
from have
group by var1, var2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 10:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558860#M10187</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T10:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558872#M10190</link>
      <description>&lt;P&gt;Some of us don't understand R code. However, you talk about 2 categorical variables, but you show an example with three variables, which is confusing. Could you show us the input SAS data set, and the desired output?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 11:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558872#M10190</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-15T11:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558873#M10191</link>
      <description>&lt;P&gt;thanks, KurtBremser,&lt;/P&gt;&lt;P&gt;I must admit though that doesn't seem to be working for me - I suspect my question wasn't clear.&lt;/P&gt;&lt;P&gt;So I adapted some code/data online and run the code - is this what was intended ? I do just get the counts rather than all combinations - there is no entry in want for name=Raj and amount=20 for example&lt;/P&gt;&lt;PRE&gt;data have;
  input NAME $ AMOUNT ;
  datalines;
RAJ     90  &lt;BR /&gt;RAJ     40
RAVI    20  
JOHN    30  
JOSEPH  40  
run;

proc sql;
create table want as
select name, amount, count(*) as count
from have
group by name, amount;
quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;many thanks again for your help&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 11:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558873#M10191</guid>
      <dc:creator>bnorth66</dc:creator>
      <dc:date>2019-05-15T11:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558875#M10192</link>
      <description>&lt;P&gt;thanks, Paige, good point the first column in the "R" example is jus the row number that R inserts - it is confusing apologies&lt;/P&gt;&lt;P&gt;for the data set I sent earlier the output I'd want would be&lt;/P&gt;&lt;PRE&gt;RAJ 20 &amp;nbsp;&lt;BR /&gt;RAJ 30 &amp;nbsp;&lt;BR /&gt;RAJ 40&lt;BR /&gt;RAJ 90 &lt;BR /&gt;RAVI 20 &amp;nbsp;&lt;BR /&gt;RAVI 30 &amp;nbsp;&lt;BR /&gt;RAVI 40&lt;BR /&gt;RAVi 90  
JOHN 20 &amp;nbsp;&lt;BR /&gt;JOHN 30 &amp;nbsp;&lt;BR /&gt;JOHN 40&lt;BR /&gt;JOHN 90 
JOSEPH 20 &amp;nbsp;&lt;BR /&gt;JOSEPH 30 &amp;nbsp;&lt;BR /&gt;JOSEPH 40&lt;BR /&gt;JOSEPH 90  
run;&lt;/PRE&gt;&lt;P&gt;thanks again for all your advice&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 12:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558875#M10192</guid>
      <dc:creator>bnorth66</dc:creator>
      <dc:date>2019-05-15T12:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558876#M10193</link>
      <description>&lt;P&gt;I think you need to use a Cartesian join in PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select a.name,b.amount
         from have(keep=name) a,have(keep=amount) b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 12:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558876#M10193</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-15T12:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558895#M10198</link>
      <description>&lt;P&gt;You need to do a cartesian join with distinct, then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select distinct
  a.name as name,
  b.amount as amount
from have a, have b
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 13:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558895#M10198</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T13:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558900#M10201</link>
      <description>&lt;P&gt;So you only want the combinations based on the values that actually appear in the data?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not ALL of the possible combinations based on some external definition of the population of possible values for those two variables?&lt;/P&gt;
&lt;P&gt;For the latter you would need some other source of the list of possible values.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 13:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558900#M10201</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T13:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558919#M10203</link>
      <description>&lt;P&gt;many thanks, Paige and Kurt, both methods work brilliantly so I'm spoilt for choice &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;yes, thats right Tom - just the values in the actual data set would be OK at the moment though I can see maybe your more general problem might be useful sometimes too&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks again for all your help - sorry I'm a bit of a novice SAS user&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 13:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558919#M10203</guid>
      <dc:creator>bnorth66</dc:creator>
      <dc:date>2019-05-15T13:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558935#M10206</link>
      <description>&lt;P&gt;If you need to treat the two RAJ's in your example data as separate persons,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s code is the way to go. If it's one person, then mine with the distinct prevents the doubling of the RAJ entries.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 13:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558935#M10206</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T13:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: data set with all possible combinations of variable values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558947#M10209</link>
      <description>&lt;P&gt;Hi KurtBremser&lt;/P&gt;&lt;P&gt;ah yes ... you're right of course - I think its your code I need - many many thanks for all your help and patience !&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 14:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/data-set-with-all-possible-combinations-of-variable-values/m-p/558947#M10209</guid>
      <dc:creator>bnorth66</dc:creator>
      <dc:date>2019-05-15T14:05:32Z</dc:date>
    </item>
  </channel>
</rss>

