<?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: Need help with combinations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865507#M341807</link>
    <description>&lt;P&gt;We can't work with data in screen captures. You will need to provide a portion of your data as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;), and not in any other format.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2023 17:28:22 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-03-21T17:28:22Z</dc:date>
    <item>
      <title>Need help with combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865478#M341790</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table in SAS that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Leiviboy_1-1679415885134.png" style="width: 816px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81828i957A01E79910C81E/image-dimensions/816x718?v=v2" width="816" height="718" role="button" title="Leiviboy_1-1679415885134.png" alt="Leiviboy_1-1679415885134.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I want the have one value for each column like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;permutation&lt;/TD&gt;&lt;TD&gt;first_stat&lt;/TD&gt;&lt;TD&gt;second_stat&lt;/TD&gt;&lt;TD&gt;third_stat&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6721&lt;/TD&gt;&lt;TD&gt;Multishot&lt;/TD&gt;&lt;TD&gt;Critical Chance&lt;/TD&gt;&lt;TD&gt;Critical Damage&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone know how to do this with code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 16:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865478#M341790</guid>
      <dc:creator>Leiviboy</dc:creator>
      <dc:date>2023-03-21T16:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865502#M341803</link>
      <description>&lt;P&gt;Can you reword your request, as I do not understand how you are going from your input "have" data to your output "want" data&lt;BR /&gt;If this helps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;What are the rules that you are applying&lt;/LI&gt;
&lt;LI&gt;Why does your "want" data have multiple identical rows&lt;/LI&gt;
&lt;LI&gt;What have you tried? Provide sample data, code and the log&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Basically the more information you provide in as simple form as possible the greater the chance you will get a helpful response.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's an example (not related to this post)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample "have" data */
data have ;
	format 
		date1 date.
		date2 date.
	;
	do i=1 to 10 ;
		date1 =today()+int(ranuni(1)*30) ;
		date2 =today()+int(ranuni(2)*30) ;
		output have ;
	end ;
run ;

/* What I tried */

proc sql ;
	create table want as
 	select intck('day',date1, date2) as c_los
 	from have 
	where c_los&amp;lt; 10 ;
;
quit ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 17:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865502#M341803</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2023-03-21T17:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865507#M341807</link>
      <description>&lt;P&gt;We can't work with data in screen captures. You will need to provide a portion of your data as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;), and not in any other format.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 17:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865507#M341807</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-21T17:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865520#M341819</link>
      <description>&lt;P&gt;Here is one way to provide example data as a data step. I'm using delimited with , because I have no idea what you actually have but the comma helps with some issues around reading the spaces embedded in string values.&lt;/P&gt;
&lt;PRE&gt;data example;
   infile datalines dlm=',';
   informat permutation f8. first_stat second_stat third_stat $15.;
   input permutation first_stat second_stat third_stat ;
datalines;
6721,Multishot,Critical Chance,Critical Damage
6721,Critical Chance,Multishot,Critical Damage
6721,Critical Damage,Multishot,Critical Chance
6721,Critical Damage,Critical Chance,Multishot
;
&lt;/PRE&gt;
&lt;P&gt;If the request is actually to re-order the values then perhaps:&lt;/P&gt;
&lt;PRE&gt;data want;
   set example;
   call sortc(third_stat, second_stat, first_stat);
run;&lt;/PRE&gt;
&lt;P&gt;The &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n00aheqlqf6qdln1og24z2hcsfd6.htm" target="_self"&gt;Call Sortc function&lt;/A&gt; sorts the variables shown so that the result will have the lowest sort order value in the first parameter, the second lowest in the second and so on. The order you showed implies that you want the first_stat to have the highest sort value (M comes after C) and it happens that "Damage" would come after "Chance" so that determined the order of the variables in the call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this related to a role-playing game by any chance?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;[Admin - Added documentation link to SORTC Function]&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 14:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865520#M341819</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-22T14:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865583#M341831</link>
      <description>&lt;P&gt;That is a very good solution&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 19:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865583#M341831</guid>
      <dc:creator>Leiviboy</dc:creator>
      <dc:date>2023-03-21T19:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with combinations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865587#M341834</link>
      <description>Yes it's related to a game</description>
      <pubDate>Tue, 21 Mar 2023 20:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-combinations/m-p/865587#M341834</guid>
      <dc:creator>Leiviboy</dc:creator>
      <dc:date>2023-03-21T20:11:50Z</dc:date>
    </item>
  </channel>
</rss>

